[FFmpeg-devel] [PATCHv2] lavf: add av_guess_frame_sample_aspect_ratio function
cus at passwd.hu
Sat May 5 21:51:05 CEST 2012
On Sat, 5 May 2012, Reimar Döffinger wrote:
> On 5 May 2012, at 19:30, Marton Balint <cus at passwd.hu> wrote:
>> On Mon, 30 Apr 2012, 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
>>> otherwise use the frame aspect ratio. This way a container setting, which is
>>> usually easy to modify can override the coded value in the frames.
>> What do you think guys, is this ready to be part of the API? I have some pending ffplay patches which depend on this functionality.
> Not sure, will this function be able to survive adding e.g. code to detect aspect changes and switch to the AVFrame on for example?
Well, I thought about that and finally I thought that it is better to
stick to a simple function which does not involve keeping track of the
state. I think it would be a bit strange to have a function that may
return two different aspect ratios for a single frame, one if we play the
movie from the start, and another if we seek to the middle of it and start
playing it from there. One can always create a filter for that.
I think the goal is not to make this function extra smart
which makes the biggest percent of users happy, but rather make the
guessing logical and consistent in undefined cases, and of course make it
work in defined cases (well, imagine a format which contains a default
aspect ratio setting and an override aspect ratio setting, the former
would have lower priority than the cocec aspect ratio, the latter would
have higher priority)
> Or some codec-dependant stuff, will all necessary information likely be available like this or might we want to have a codec and/or format context?
I can make a third parameter for AVFormatContext, probably it would not do
> And since it is in libavformat, should the second parameter be an AVFrame or should it maybe rather just be the frame aspect so it can be more easily used with codecs other than libavcodec?
I thought using AVFrame ensures bigger flexibility in terms of determining
the aspect, but at the moment I can't imagaine any sane example, so I
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
More information about the ffmpeg-devel