[FFmpeg-devel] [PATCH] read sample aspect ratio from video stream if not known from container

Michael Niedermayer michaelni
Tue Feb 10 12:40:53 CET 2009

On Tue, Feb 10, 2009 at 11:53:41AM +0100, Pawe? Ko?odziej wrote:
> Dnia 2009-02-09, Pn o godzinie 23:01 +0100, Michael Niedermayer pisze:
> > On Mon, Feb 09, 2009 at 04:55:53PM +0100, Pawe? Ko?odziej wrote:
> > > Hello,
> > > 
> > > File 
> > > http://derchris.eu/ccc/25C3/video_h264_720x576/25c3-2596-en-swf_and_the_malware_tragedy.mp4
> > > (h264 in mp4) has SampleAspectRato 5:4 but information about it is not
> > > stored in container but in video stream (VUI). This information is not
> > > read by ffmpeg[1] and this results in output stream with SAR 1:1
> > > (wrong).
> > > 
> > > Attached patch fix it - if SAR is not known from container then it's
> > > read from video stream. I hope it does not break anything. 
> > 
> > a file that contains no aspect at all will cause av_find_stream_info()
> > to run for a very long time with this patch
> It will read and decode no more then MAX_READ_SIZE which is 5Mbytes. I
> think it will take no longer then about 5-10s (on PC). For me it does
> not sound like "very long time" - usual ffmpeg run take about an hour or
> so. 

more than 10ms is too long
libav* is used by players, do you want to explain to their users why they
have to wait 5-10sec before the player starts?

> Do you have any idea to improve this worst case in which 5MB of stream
> will be read? I've only one: we could add special mode to decoders in
> which they do not perform full video decoding but only looks for
> headers. But it will be needed to change all decoders - it may be quite
> a big job.  

* more fine grained control of how far to look for what information 
  nothing bad should happen if we look at the first frame for the aspect.
* flags or num of bytes limits so the user of av_find_stream_info()
  can specify how far to search for what.

> Anyway this patch fixes bug - without it some contents are endoded with
> wrong aspect ratio.

this patch adds a new bug as well

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090210/c0b9ddf1/attachment.pgp>

More information about the ffmpeg-devel mailing list