[Libav-user] Unable to find codec

Nicolas George nicolas.george at normalesup.org
Mon Jan 9 15:04:55 CET 2012


Le decadi 20 nivôse, an CCXX, francesco-V8Dg30rvLxeB+jHODAdFcQ at public.gmane.org a écrit :
> I compiled last release of ffmpeg with all codecs enabled. So I linked the
> libraries to my project and opened a simple image composed with a single field.
> The av_open_input_file, and av_find_stream_info(pFormatCtx) works correctly,
> that is info contained into pFormatCtx are correct (video stream is a MPEG2
> one).The problem arises when I attempt to detect codec.  Here is the code:
> 
>   videoStream=-1;
>   for(i=0; i<pFormatCtx->nb_streams; i++)
>     if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) {
>       videoStream=i; break;
>     }
> 
>   if(videoStream==-1) {Memo1->Lines->Add("Unable to detect stream type");
> goto   end_conv;}

Note that you can use av_find_best_stream for that.

>    // Get a pointer to the codec context for the video stream
>   pCodecCtx=pFormatCtx->streams[videoStream]->codec;
> 
>   // Find the decoder for the video stream
>   pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
> 
> The pCodec is always null.  Did anyone have an idea ?

Did you forge to call some of the register_all?

If not, trim your program until remains only the bare minimum to show the
problem; do not hesitate to hardcode filenames or even codec ids. The result
should probably be less than 20 lines. Then post it here as a whole.

Regards,

-- 
  Nicolas George


More information about the Libav-user mailing list