[FFmpeg-devel] CrystalHD and ffmpeg probe behaviour

Philip Langdale philipl at overt.org
Sun Jan 15 22:40:34 CET 2012


On 14.01.2012 16:23, Reimar Döffinger wrote:
> On Sat, Jan 14, 2012 at 03:23:32PM -0700, Philip Langdale wrote:
>> Is there some combination of options that will do this or is there a
>> software limitation
>> I need to fix?
>
> IMO ideally you'd just change ffmpeg to reconfigure itself when
> the pix_fmt changes.
> I don't think there is any real need for it to know it until after
> a frame was actually decompressed.

I suppose, but that seems like a fair amount of new logic. The 
fundamental
problem is how avformat_find_stream_info is called. The codec is 
specified
by id, even though you specify the vcodec by name. This means it will 
use
the first decoder that matches the id. If we could pass the name in and 
then
do a lookup by name, it should all work out.

As a bit of a hack, I did the following to set the pix_fmt from the 
user
specified decoder and it works, but it's ugly:

diff --git a/ffmpeg.c b/ffmpeg.c
index 434302d..1bd3cd4 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3464,6 +3464,7 @@ static AVCodec *choose_decoder(OptionsContext *o, 
AVFormatContext *s, AVStream *
      if (codec_name) {
          AVCodec *codec = find_codec_or_die(codec_name, 
st->codec->codec_type, 0);
          st->codec->codec_id = codec->id;
+        st->codec->pix_fmt = *(codec->pix_fmts);
          return codec;
      } else
          return avcodec_find_decoder(st->codec->codec_id);


--phil


More information about the ffmpeg-devel mailing list