[FFmpeg-devel] [PATCH] lavf: add av_guess_frame_sample_aspect_ratio function
Reimar.Doeffinger at gmx.de
Sun Apr 29 16:03:01 CEST 2012
On Sun, Apr 29, 2012 at 02:51:17PM +0200, Michael Niedermayer wrote:
> On Sun, Apr 29, 2012 at 01:10:15PM +0200, Reimar Döffinger wrote:
> > 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.
> it should be fairly easy to write a bitstream filter that can change
> the aspect ratio
For all video stream formats that contain such info?
It may be easy but it sure is a good bit of effort.
And it doesn't change the fact that it is not possible currently,
and even if it was it probably still wouldn't be in lots of other
applications that can change the container info just fine (mkvmerge
for example I believe still can only set the container info).
And I don't think a sample aspect of 1:1 is particularly unusual
so that using it as an error indicator would be really justified.
More information about the ffmpeg-devel