[FFmpeg-user] Getting actual video size + ratio

Nicolas George nicolas.george at normalesup.org
Wed Nov 21 11:46:15 CET 2012

Le primidi 1er frimaire, an CCXXI, Nathan Malachowski a écrit :
> Hi i'm trying extract images from movie files and i'm running into an issue
> of scaling when trying to fit them within a specific aspect ratio. Below is
> the stream output of the video
> Stream #0.0(eng): Video: mpeg4, yuv420p, 720x480 [SAR 1:1 DAR 3:2], 6473
> kb/s, SAR 40:33 DAR 20:11, 29.97 fps, 29.97 tbr, 2997 tbn, 1k tbc
> the video says its 720x480 with square pixels, but then later the second PAR
> 40:33 DAR 20:11 s confusing. I realize this means the pixels are stretched,
> and any media player shows it at 854x480 , but i don't know how i would
> determine that using the second set of sar:dar values. why would there be 2
> sets anyway?

FAQ: Q: Why are there two sets of aspect ratios?

A: Because there are (at least) two places the aspect ratio can be stored,
and bogus videos can have different values there.

In the ffmpeg summary, the aspect ratio between brackets is the aspect ratio
stored in the video bitstream, at the codec level; the aspect ratio outside
the brackets is the aspect ratio stored in the container format.

The aspect ratio in the container is usually considered more reliable
because it is easier to change. At the API level, you can use the
av_guess_sample_aspect_ratio() function to use various heuristics to try and
find the correct one.

> i'm also parsing this output with php to grab various values, so 720x480
> would be incorrect and i'd have to check for the second set of values and
> if they exist apply them to the video size parameter so it represented the
> actual display size/ratio, which i then use to generate thumbs. The
> question is how to calculate that too.

I do not understand the question.


  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-user/attachments/20121121/2bb44645/attachment.asc>

More information about the ffmpeg-user mailing list