News:

--

Main Menu

MP4 container SAR always 1:1 if none is specified?

Started by CryGuy, July 20, 2020, 02:36:03 PM

Previous topic - Next topic

CryGuy

Hi,

I'm transcoding an MPEG-2 720x576 (DAR=16:9) video.
Codec=x264. DAR=16:9 (on the "IDC/SAR" tab)
Muxer=MP4, no DAR is set explicitly by myself.

Analyzing the resulting video with ffmpeg, it outputs
720x576 [SAR 64:45 DAR 16:9], 1947 kb/s, SAR 1:1 DAR 5:4, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)

The values in brackets are from the stream, which is as expected. My question is: Where is "SAR 1:1 DAR 5:4" coming from even though I did not specify a container DAR? Is there always a container AR written even if I don't specify one explicitly?

(I'm aware that the container AR is more relevant as stated by eumagga0x2a in this thread.)

Thanks in advance for clarifying.

.......BTW, my favorite player is MPC-HC using the LAV decoder. There you can select which AR to be used: a) container, b) stream, c) stream only if there is no container AR. I've chosen the latter one. If I watch the transcoded video mentioned above, the DAR is 1:1. I expect DAR 16:9 because I did not specify a container AR, so it should fallback to the stream AR which is 16:9.

eumagga0x2a

Quote from: CryGuy on July 20, 2020, 02:36:03 PM
Analyzing the resulting video with ffmpeg, it outputs
720x576 [SAR 64:45 DAR 16:9], 1947 kb/s, SAR 1:1 DAR 5:4, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)

The values in brackets are from the stream, which is as expected. My question is: Where is "SAR 1:1 DAR 5:4" coming from even though I did not specify a container DAR?

I think, Avidemux always sets 1:1 as fallback if not configured otherwise, which explains the behaviour of MPC.

CryGuy

QuoteI think, Avidemux always sets 1:1 as fallback if not configured otherwise, which explains the behaviour of MPC.
So this is a decision made for Avidemux but not essential for the mp4 container in general.

Thanks!

CryGuy

#3
If I may add a related question: Which tool reports all AR values from a file reliably? The results from different tools vary or are not clear. For example, ffmpeg doesn't report a container DAR if it is equal to the stream DAR. Consequently, I don't know if either there is no container DAR stored at all, or if it's equal to the stream AR.

eumagga0x2a

#4
What is wrong with MediaInfo?

The reality is that not setting DAR at container level is simply impractical, so unless for the purpose of software development and testing, I'd always set it to the desired value.

addendum: The above doesn't mean that Avidemux does it right.

CryGuy

QuoteWhat is wrong with MediaInfo?
I did not mention it...
Nothing is wrong with it. I just can't verify if it's right as I don't have a reference that tells me what is correct.
MediaInfo says "Display Aspect Ratio", and optionally "Original Display Aspect Ratio". Both listed with the video stream. I do not know if one of them is at container level. Does that "Original" mean?

QuoteThe reality is that not setting DAR at container level is simply impractical, so unless for the purpose of software development and testing, I'd always set it to the desired value.
I will, but now I'm about to verify several files from my archive. Only some hundreds...

Thank you.
(And another big thanks! for the many new messages I receive from my RSS reader subscribed to avidemux2:master @ github. ;) Great work.)

eumagga0x2a

Quote from: CryGuy on July 21, 2020, 08:57:10 PM
MediaInfo says "Display Aspect Ratio", and optionally "Original Display Aspect Ratio". Both listed with the video stream. I do not know if one of them is at container level. Does that "Original" mean?

Honestly, I am not sure myself. To avoid ambiguity, I recommend

mediainfo --Details=1 /path/to/file | egrep "Track width|Track height|Width|Height|hSpacing|vSpacing"

For a 720x576 widescreen H.264 video I get e.g.

0000F0    Track width:                         1024.000
0000F4    Track height:                        576.000
0001F5        Width:                           720 (0x02D0)
0001F7        Height:                          576 (0x0240)
000269         hSpacing:                       64 (0x00000040)
00026D         vSpacing:                       45 (0x0000002D)
0099E9    Track width:                         0.000
0099ED    Track height:                        0.000


The leftmost column is the offset in the file where a particular entry begins, "Track width" and "Track height" denote the display size of the track, stored in the track header (tkhd box). They are used to calculate the display aspect ratio at the container level.

"Width" and "Height" hold the pixel size of the video, "hSpacing" and "vSpacing" are pixel aspect ratio numerator and denominator. The both last pairs of values are stored in the avcC box (codec extradata).

Thank you :-)

CryGuy

Thanks for the explanation.
You were faster... I was about to write that I found a way: I simply configured mpc-hc to always use the container ratio, so I just see if the AR is wrong/missing, and with [PgDown] (jump to the next video inside mpc-hc) I can quickly process folders.
Servus. ;)