Log in

View Full Version : How do you implement Cropping & resizing


john blox
7th July 2003, 21:13
What is the logic for converting an anamorphic clip x_px * y_px to a resized & cropped version with the CORRECT aspect ratio for avi conversion.

I have searched and read through many posts on these forums regarding aspect ratios but am really none the wiser other resize thread (http://forum.doom9.org/showthread.php?s=&threadid=33355&highlight=aspect+ratio) came close but then drifted off into confusion. I would work out the maths myself but don't actually understand how its supposed to work in the first place. I spent a few hours trying to retro-engineer the results 'video size calculator' gives but concluded that without knowing what was supposed to be going on in the first place i couldn't find any logic.

eg for a 704X576 anamorphic to get 576x??? it says crop to 704*571 then resize to 576*320 - but how are these figures arrived at. I understand that anamorphic implies a 33% horizontal stretch and avi requires 1:1 ratio but.....?

DaveEL
7th July 2003, 22:19
Originally posted by john blox
eg for a 704X576 anamorphic to get 576x??? it says crop to 704*571 then resize to 576*320 - but how are these figures arrived at. I understand that anamorphic implies a 33% horizontal stretch and avi requires 1:1 ratio but.....?


Its probably best if you look at some source instead of the discussions then :)

Take a look at gordianknot for pixel aspect ratio values. My quick2pass source is around on http://daveel.dnsalias.com but i just got the values from the gordianknot output (and a bit of creative rounding :) ) but it may be slightly easier to find where these values are used (gordianknot is big q2p is small :)) if you can't find it give me a shout and i will go through it with you.

DaveEL

john blox
8th July 2003, 13:51
ok Checked out your source 328/225 & 82/75 seem like the magic numbers that I kept getting but didn't know why (where do they come from?). OK so I can now calculate the right values for the crop/resize for mpeg2 files but what about mpeg1?

I have these vals read from the mpeg file

Width
Height
aspect (1..4 => 1:1..2.21:1)
FPS (1..8 => 23.97..60)

1) For MPEG2 What value should I use to determine if it is PAL /NTSC - Either the frame rate or the height I Guess. eg if fps <> 25 then => NTSC OR if Original Height < 500 (ie 480) then => NTSC?

2) To determine if it is mpeg1 I can assume if width = 352 then it is MPEG1 (aspect for mpeg1 seems to = 8 or 12 whatever that means?), but what about the aspect ratio magic number for that? is it PAL (82/75) or NTSC (10/11) or some other value. These files seem to be mainly 352x288 or 352x240. Are all MPEG1's the same or are there PAL stretched & NTSC stretched ones, if so whats the best way to deduce from above params what it is.


Thanks for your help

DaveEL
8th July 2003, 14:56
try looking here http://www.mir.com/DMG/aspect.html (and at the links at the bottom)

DaveEL

john blox
8th July 2003, 16:34
OK cheers it seems to all be working ok now consistently with other auto-resizers (give or take a pixel)