Log in

View Full Version : 720x480 video (how to calculate actual width of 872x480)


mpfundstein
8th February 2013, 22:21
Hey Doom9,

i am working on a avisynth scripts which automatically resizes videos to 720x576 (ar 16/9), with automatic boxing or cropping.

One of my source videos has a size of 720x480 with a 16:9 dar and a par of 32/27. All my calculations showed me that the actual width should be 854 but if I open the video in quicktime, it reports 872. Funny enough, my formula works perfect when i use it with 872 but breaks with 854. So somehow i need to find out how to calculate the actual width of 872.

The source video is 720x480. Here is the ffprobe output

https://gist.github.com/MarkusXite/e7f3b032fe698041c985

The correct calculations are:

resized_height = 480 * 1024 / 872 -> 563.669
crop_height = (576 - 563.669) / 2 -> 6.17 ~ 6 (perfect)

With 854 crop_height => -0.113

Can someone help me on that?

P.S. I get 854 by using 720*32/27
P.P.S 720 x 16/9 = 1280

Regards,
Markus

Pomegranate
8th February 2013, 22:31
You should crop first and then resize.

I'm confused, is your source 720x480 or 720x576?

mpfundstein
8th February 2013, 22:54
thanks for your answer.

The source video is 720x480. Here is the ffprobe output

https://gist.github.com/MarkusXite/e7f3b032fe698041c985

-- Just saw the typo. thanks

Pomegranate
8th February 2013, 23:03
Quicktime is using a par of 40/33. 720 * 40/33 =~ 872

I'm still unsure what you are trying to do. You want to do 720x480 -> 720x576?

mpfundstein
8th February 2013, 23:13
Hey Pomegranate. Can you explain why Quicktime is using a different PAR than what is written in the video meta data?

Yes, i try to do: 720x480 to 720x576 , anamorphic 16/9

and i am actually able to do it with the formula above. But only if i use the formula with 872...

Pomegranate
8th February 2013, 23:24
Well, it would take me a long time to explain, but try here http://en.wikipedia.org/wiki/Pixel_aspect_ratio#Analog-to-digital_conversion

Basically, Quicktime assumes 704x480 to be 16:9 for all mpeg-2 with a 16:9 flag. As you can see, (480*16/9) / 704 = 40/33.

But you don't really need to do all those calculations if you're going from 720x480 (16:9) to 720x576 (16:9). Just resize(), if your video is progressive.

mpfundstein
8th February 2013, 23:27
If i just resize, my picture is played out vertically stretched. Thats why i do all this. I am not allowed to have any {vertical,horizontal}-only stretching of the content.

But major thanks about the quick time explanation. Can i ask you where you got this information from? So actually Quicktime assumes a video width of 704, ignoring the 720 , calculates the PAR (40/33) from that and than upscales the 720 by 40/33 ? The PAR from ffprobe gets than ignored as well right?

Pomegranate
8th February 2013, 23:41
After resizing, you have to encode your video with a 16:9 flag in your video encoder. Then, it won't be vertically stretched. If you're previewing your avisynth script in virtualdub, right-click on either input pane or output pane and set the aspect ratio to 16:9 and it will display properly.

Most of the commercial softwares use 40:33 par for for 720x480 16:9 ntsc. Quicktime does not adjust the dar the way you're thinking. It just does 720 * 40/33 and leaves the height untouched.

I did not get the information about quicktime from anywhere, I just did the math and it worked out :p

mpfundstein
8th February 2013, 23:47
lol :-) ok.

Well, the thing is. my video is intended to be broadcasted on television. Our playout software unfortunately ignores the aspect ratio flag completely.. It justs stretches everything to 720x576 (1024x576 respectively). So the video has to be perfectly sized etc. But you are right. VLC player for example does everything correct as well..

Pomegranate
8th February 2013, 23:57
Okay, so, your playout software will respect the Picture Aspect Ratio? Does it resize while keeping picture aspect ratio?

If I'm understanding this properly, you have to feed a 16:9 video with 1:1 Pixel aspect ratio to the software?

mpfundstein
9th February 2013, 08:45
yes. I have two options

1024x576 with a par of 1:1
720x576 with a sar of 64:45

it is all still a bit confusing to me tbh...

Pomegranate
9th February 2013, 09:09
Then resize your video to 720x576.

16:9 720x576 has a SAR of 64:45.

Are you able able to test your video on the playout software before it is broadcast? Encode a short segment, like a minute or so and try it out.

mpfundstein
9th February 2013, 09:17
don't get me wrong but a) i do this already (720x576, 16/9) and b) it works fine. My question was how the 872 was computed. Not more or less. But big thanks for your help. I appreciate that.

TheSkiller
9th February 2013, 11:06
The 872 was computed by taking into account which portion of the 720x480 frame actually carries the active video signal in analog video signals. Yes, it's not the whole 720x480 frame that's carries the image, it's much more complicated than that. But nowadays many people seem to ignore this and simply assume it does.

Now let's do the math.

The simplified(!) active image area is 704x480 right in the center of 720. This exact area carries your 4:3 or anamorphic 16:9 image.

Now, how much additional overhead width do we have until we reach 720?
It's (720 / 704).

Our 16:9 standard square pixel width is 853.333 pixels (it's exactly 16:9).

So we need to make it (720 / 704) times wider than that to cope for the additional width:
853.333 * (720 / 704) ≈ 872.72

And there you have your 872 or 873 which can be scaled straight to 720x480. :)


I hate to say it but Quicktime is absolutely correct.

mpfundstein
10th February 2013, 00:47
you really have no idea how grateful i am. TOP EXPLANATION! And a lot of info hard to find. I was reading a lot about this. Active Image and Reported Image. Very interesting subject but discovered it just 1 day ago. You're answer brought me immediately to more understanding. thanks

(und gruesse an die heimat aus amsterdam ;-) )

P.S. you ! simplified because its actually 710x486 komma s.th. right?

TheSkiller
10th February 2013, 12:29
Thanks, nice to help you. :)

P.S. you ! simplified because its actually 710x486 komma s.th. right?
Yes, that's it if we're really strict (it's 710.85x486). But it's better to use the simplified numbers (704x480) because the aspect ratio is just as correct when using 704x480, which fits conveniently into the common frame size of 720x480. The only difference would be the overall image is very slightly smaller compared to 710.85x486. But we would have to round it to 711 which is a nasty number of pixels to deal with in digital video since it's not divisible by 2. :devil:
TV broadcasters use 720x486 internally to cover up everything there is, and if needed, like for broadcast, the six additional scanlines are simply cropped off. So basically, there's no drawback at all when using 704x480.

Greetings back to Amsterdam. ;)