Discussion:
[FFmpeg-user] Two SAR/DAR pairs (codec and stream SAR/DAR)
Nikita Skalkin
2015-11-30 14:27:43 UTC
Permalink
Hello everyone! In our company, we use ffmpeg to parse video info and
convert it, according parsed info. Recently we found a bug in our system.
When calling ffprobe for video, we got 2 SAR/DAR pairs.


Example:


Stream #0:0(eng): Video: mpeg2video (4:2:2) (mx3p / 0x7033786D),
yuv422p(tv, bt470bg/smpte170m/bt709), 720x608 [SAR 152:135 DAR 4:3], 30105
kb/s, SAR 35:24 DAR 525:304, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)


In our system we use first pair for detecting video aspect. But in test
video it gives us not correct aspect (for our algorithms), whilst second
pair is right.


I found commit (082491c), that explains second pair. Commits comment says
that ffmpeg prints second pair if stream SAR differs from codec SAR. But I
coundn’t find what is codec SAR, and why it differs from streams SAR. Could
you explain it for me?


Thanks for your help!
Tobias Rapp
2015-12-01 08:32:14 UTC
Permalink
Post by Nikita Skalkin
Hello everyone! In our company, we use ffmpeg to parse video info and
convert it, according parsed info. Recently we found a bug in our system.
When calling ffprobe for video, we got 2 SAR/DAR pairs.
Stream #0:0(eng): Video: mpeg2video (4:2:2) (mx3p / 0x7033786D),
yuv422p(tv, bt470bg/smpte170m/bt709), 720x608 [SAR 152:135 DAR 4:3], 30105
kb/s, SAR 35:24 DAR 525:304, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
In our system we use first pair for detecting video aspect. But in test
video it gives us not correct aspect (for our algorithms), whilst second
pair is right.
I found commit (082491c), that explains second pair. Commits comment says
that ffmpeg prints second pair if stream SAR differs from codec SAR. But I
coundn’t find what is codec SAR, and why it differs from streams SAR. Could
you explain it for me?
Some video codecs allow to store the aspect ratio within the binary data
chunk of each encoded frame. Also some container formats allow to store
the aspect ratio globally for the whole stream (file). Now when both
values exist they possibly contain mismatching information. Which value
is the correct one is not obvious, I guess media players have some own
guessing algorithm to decide which one to use.

Regards,
Tobias
Carl Eugen Hoyos
2015-12-03 14:19:34 UTC
Permalink
Post by Tobias Rapp
I coundn’t find what is codec SAR, and why it differs from streams SAR.
Could you explain it for me?
SAR - sample aspect ratio or pixel aspect ratio

It can differ for several reasons including bugs in the recording software.
Post by Tobias Rapp
Some video codecs allow to store the aspect ratio within the binary data
chunk of each encoded frame. Also some container formats allow to store
the aspect ratio globally for the whole stream (file). Now when both
values exist they possibly contain mismatching information. Which value
is the correct one is not obvious, I guess media players have some own
guessing algorithm to decide which one to use.
It makes sense to use the container aspect ratio if they disagree.

Carl Eugen

Loading...