3

I was trying to do some video editing and encoding. I have a so-called SD video that should supposedly be in 4:3 aspect ratio. But instead of 640x480, it is 720x480. Interestingly, when I play it with a media player, what I see is 640x480- it is not played as 720x480!

What is going on?! How could it be possible?

4

525/60 digitized SD video according to Rec. 601 is indeed 720 pixels wide, 480 pixels high, including some blanking on the sides. Digital equivalent of 625/50 is 720x576. In both cases, frame aspect ratio is 4:3, this simply means that the pixels are not square. See https://en.wikipedia.org/wiki/D-1_(Sony)

To make matters more complex, only a subset of the frame has 4:3 proportions. I believe, only the 704x480 (for 525/60) and 704x576 (for 625/50) has 4:3 proportions. See discussion here: https://lurkertech.com/lg/video-systems/

So, 480 pixels are 10/11 in proportion, 576 pixels are 59/54 in proportion. Also see here: https://en.wikipedia.org/wiki/Pixel_aspect_ratio And do not forget, that both 480-line and 576-line formats can also be widescreen (16:9) yet having the same number of pixels per line! Plus, numbers like 59/54 are not easy to work with. All of this caused that for 576-line format pixel aspect ratio has been chosen as 12/11 for 4:3 screen aspect ratio, and as 16/11 for 16:9.

Square pixels became the norm starting from VGA video adapter I believe, and then from HD specs for 720-line and 1080-line video. By the way, there are some HD formats that record 1440x1080 or 960x720, yet having 16:9 frame aspect ratio, they also have non-square pixels. Square pixels are relatively recent development and should not be automatically expected.

  • Thanks for the description. I'm playing around with FFmpeg for some experiments (to see if the two have same scene-cut lengths). So since the playback is the same, should I assume from ffmpeg, the 640x480 and 720x480 are identical?! – Tina J Jan 3 at 23:02
  • 3
    ffmpeg, (not ffplay) never rescales videos to the display aspect ratio, so filters and encoders will only operate upon the raster data, which is 720x480, in your case. – Gyan Jan 4 at 10:47
  • non square pixels would probably require you to re-sample the video, the worst kind of transcoding known to mankind, in order to fix it. – TravisO Jun 13 at 19:03
2

There are 2 different things:

  • The real width and height of frames (in pixels) - see the green part of the folowing picture.
  • The displayed width and height (during the playback) - see the blue part of the same picture.

The problem arose in old bad days, when the resolution of devices (number of pixels in the image) was very low, but the required ratio of width to hight for the playback was 4:3.

The solution (in those days) was the invention of non-square pixels.


For the sake of simplicity let's suppose (theoretically) very low dimensions:

  • required: 4 x 3 pixels (i. e. 12 pixels) per frame.
  • real possible (for the acceptable price): 3 x 3 (i. e. 9 pixels).

The solution was non-square pixels with the pixel aspect ratio (PAR) 4:3, as here:

enter image description here

So the pixel aspect ratio (PAR) is the ratio of sizes of every one individual pixel:

Every blue pixels in our image has PAR 4:3, and every orange and every green one has PAR 1:1.

Now our whole (blue) image is displayed correctly, as we wanted - e. g. as 12 cm x 9 cm - so its Display Aspect Ratio (DAR) is 12:9, or 4:3.

In spite of it, it's saved as 3 x 3 pixels - so the Storage Aspect Ratio (SAR) is 3 pixels : 3 pixels, or 1:1.

Hint:

  • pixel aspect ratio (PAR) is micrometers : micrometers
  • display aspect ratio (DAR) is centimeters : centimeters
  • storage aspect ratio (SAR) is pixels : pixels

Consequently the relation between these 3 values is

              DAR = SAR × PAR

The important note:

Sometimes is PAR (Pixel Aspect Ratio) called Sample Aspect Ratio - as in FFmpeg. Unfornately, the abbreviation for it is then SAR, which is very confusing, because - as we saw - it's also the abbreviation for Storage Aspect ratio.


The main problem:

Nowadays all devices have pixel aspect ratio 1:1 (square pixels), and many media players, mainly for small devices (cell phones, tablets), rely on it, fully ignoring the DAR value stored in video streams.

So you may encounter the situation when the same video (made from all sources) is played back correctly in your desktop or laptop computer, but incorrectly (narrowed) in your smartphone. Or even on the other media player on the same computer or device.

In our example, the frames may be wrongly displayed as a square (see the green part of the image above).


The solution of this problem in FFmpeg:

  • resize the problematic video, then
  • set the SAR of it to 1, and
  • the DAR has very likely the correct value, but you may set it to be sure.

In our (unreal) example you may use the filtergraph

-vf scale=4:3,setsar=1,setdar=w/h

where w is the with of (just scaled) frames in pixels, h is their height. FFmpeg substitute the appropriate values automatically.

The result will be the orange part of the above image.


In your case, your video has (from your info)

  • DAR 4:3 (640:480),
  • SAR (Storage Aspect Ratio) 720:480 = 3:2, and - consequently -
  • PAR = DAR / SAR = 8:9. (In the FFmpeg terminology it is SAR - Sample Aspect Ratio).

So to avoid problems with media players ignoring the DAR value (and play back it in the proportion 720:480, you may consider to convert it with the command

ffmpeg -i your_input_file -vf -scale=640:480,setsar=1 -c:a copy your_output_file

Problems with pictures with non-square pixels:

With pictures the situation is even much worse:

Almost all Picture Viewers/Editors and Internet Browsers simply ignore images SAR and DAR, supposing that all pictures over the world have SAR 1:1.

The honorable exception is (interestingly and surprisingly enough) Microsoft Windows Photo Viewer, which displays all pictures correctly.

You may become convinced of it e. g. by the The Pixel Aspect Ratio Acid Test - all 9 pictures there should be displayed correctly in your browser, but - highly likely - they aren't.

  • well described. Thanks! Both are correct. Once the number of ups gets higher, will update the best answer. – Tina J Jun 10 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.