[FFmpeg-devel] [PATCH] lavf: add av_guess_frame_sample_aspect_ratio function
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Sun Apr 29 13:10:15 CEST 2012
On Sun, Apr 29, 2012 at 01:30:02AM +0200, Marton Balint wrote:
> Guesses the sample aspect ratio of a frame, based on both the stream and the
> frame aspect ratio.
>
> Since the frame aspect ratio is set by the codec but the stream aspect ratio
> is set by the demuxer, these two may not be equal. This function tries to
> return the value that you should use if you would like to display the frame.
>
> Basic logic is to use the stream aspect ratio if it is set to something sane
> and not 1:1, otherwise use the frame aspect ratio if it is set. I made some
> tests with the files on samples.libav.org and this logic performed the best.
It also means it will be impossible for users to fix an incorrect ratio
encoded in the H.264 headers by just modifying the container value.
Since the container value is basically always easy to trivial to fix,
while the stream one is very difficult (with FFmpeg for example the
only way possible is re-encoding) I am against ever disregarding the
container value.
In MPlayer I made one special case: when the frame value changes, that
one is used. Since that most likely means there was an aspect change
and most containers do not support those.
More information about the ffmpeg-devel
mailing list