[Ffmpeg-devel] AVCodecContext.frame_size = 1 ?

Alex alex.ctn
Tue May 24 14:47:03 CEST 2005


Refer to audio_encode_example, when I change the codec to pcm s16be,
the frame size is 1. But when I change it back to mp2, and set sample
rate as 44.1k, the frame size is reasonable. It's still 1 even if the
sample rate is 44.1k when codec is pcm.

    AVCodec *codec = NULL;
    AVCodecContext *c = NULL;
    
    codec = avcodec_find_encoder(CODEC_ID_PCM_S16BE);
    //codec = avcodec_find_encoder(CODEC_ID_MP2);
    if (!codec) {
        cout << "codec not found" << endl;
        exit(1);
    }    

    c = avcodec_alloc_context();
    
    /* put sample parameters */
    c->bit_rate = 128000; 
    c->sample_rate = 8000;
    //c->sample_rate = 441000;
    c->channels = 1;
		
		    /* open it */
    if (avcodec_open(c, codec) < 0) {
        cout << "could not open codec" << endl;
        exit(1);
    }    
    cout << "frame size " << c->frame_size << endl;





More information about the ffmpeg-devel mailing list