[FFmpeg-devel] [PATCH] ffprobe: Stash and use width and height before opening the codec

Michael Niedermayer michaelni at gmx.at
Thu Mar 7 02:58:57 CET 2013


On Thu, Mar 07, 2013 at 02:41:46AM +0100, Stefano Sabatini wrote:
> On date Thursday 2013-03-07 02:34:50 +0100, Michael Niedermayer encoded:
> > On Fri, Mar 01, 2013 at 10:41:34AM -0500, Derek Buitenhuis wrote:
> > > Some codecs, such as VP6, will only have their correct width and
> > > height set if a few frames have been decoded. This is accomplished
> > > when we call avformat_find_stream_info(). However, we call
> > > avcodec_open2() after this, which can possibly reset the width
> > > and height in the decoder's context to an erroneous value.
> > 
> > Do you have a sample file the shows this behavior ?
> 
> https://ffmpeg.org/trac/ffmpeg/ticket/1386

following seems to fix this:

--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -877,7 +877,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
         goto free_and_end;

     //We only call avcodec_set_dimensions() for non h264 codecs so as not to overwrite previously setup dimensions
-    if (!( avctx->coded_width && avctx->coded_height && avctx->width && avctx->height && avctx->codec_id == AV_CODEC_ID_H264)){
+    if (!( avctx->coded_width && avctx->coded_height && avctx->width && avctx->height &&
+           (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_VP6F))){

     if (avctx->coded_width && avctx->coded_height)
         avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130307/c2855d1a/attachment.asc>


More information about the ffmpeg-devel mailing list