[Ffmpeg-devel] What and How to set default value for AVCodecContext pointer????

Paul paul.pham
Wed Jan 31 08:29:41 CET 2007


hi all, 

i capture auido buffer. These are PCM data. And whenany have new PCM buffer, will be encoding to MPEG 1 audio frame(s). These frame will be write to file.
Now is i have to create AVCodecContext pointer,  so that later, i can use avcodec_decode_audio() before call avcodec_encode_audio(). But have inconvenient when init AVCodecContext pointer:

/* code to init AVCodecContext pointer
    argv[1] =  "temp.wav";
    if(av_open_input_file(&pFormatCtx, argv[1], NULL, 0, NULL)!=0)
        return -1; // Couldn't open file

    // Retrieve stream information
    if(av_find_stream_info(pFormatCtx)<0)
        return -1; // Couldn't find stream information
    // Find the first audio stream
    audioStream=-1;
    for(i=0; i<pFormatCtx->nb_streams; i++)
        if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_AUDIO)
        {
            audioStream=i;
            break;
        }
  
    if(audioStream==-1)
        return -1; // Didn't find a audio stream

    // Get a pointer to the codec context for the audio stream
    pCodecCtx=pFormatCtx->streams[audioStream]->codec;
*/

You can see that i open one available wav file first... i think this no good. But i donot know if i donot use one available .wav , have different way to init AVCodecContext pointer and can call avcodec_decode_audio() later without no error?
If i need to hard code some value when init AVCodecContext pointer , I donnot know what are need to set for AVCodecContext pointer? Can any help me?





More information about the ffmpeg-devel mailing list