[FFmpeg-devel] sample_aspect_ratio - which has priority?

Nicolas George nicolas.george at normalesup.org
Sat Apr 21 20:05:48 CEST 2012

Le tridi 3 floréal, an CCXX, Marton Balint a écrit :
> AVStream has an aspect ratio field
> AVFrame has an aspect ratio field as well
> AVCodecContext has an aspect ratio finally.

AFAIK, the last two are the same, except if the aspect ratio changes in
mid-stream and frames are reordered. Therefore, the aspect ratio in AVFrame
should be preferred over the one in AVCodecContext. The same goes for the
frame size, note.

As for the one of AVStream, it is the usual dilemma between information from
the container and information from the codec. In this particular case, I
believe the information from the codec is more reliable, especially since it
can change.

> I think it would be really useful to document what is the preferred
> order of these aspect ratios.

Documentation is always welcome!

> Use AVStream sample_aspect_ratio if specified
>   else Use AVFrame sample_aspect_ratio if specified

My opinion is that it should be the other way around, but I am not aware of
all possible misfeatures in various formats and codecs.

> Use AVCodecContext only if you are certain that is still holds the
> information valid for the current frame.

I do not think this one is necessary.


  Nicolas George
-------------- 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/20120421/732c79d6/attachment.asc>

More information about the ffmpeg-devel mailing list