PDA

View Full Version : Scaling a video and forcing it into a standard frame size.


demistate
4th August 2009, 01:14
I shot an anamorphic film just a few days ago, and now I need to output it to DVD. Since DVD only accepts one frame size, I need to scale the film to have the correct aspect ratio, but be within the frame size of DVD. This will actually leave black bars on the top and bottom.

Tech specs: Shot 1280x1080 DVCProHD (1.5AR)
Real aspect ratio at 1:1 should be 1920x713

That video needs to fit into a 720x480 1.2 AR file for SD DVD.

Every time I scale in Avisynth I can't lock the frame size. I didn't know if there was a command to do this or a plugin to achieve what i'm trying to do.

thewebchat
4th August 2009, 01:56
This can be a bit tricky because the PAR changes for DVD conversion, but the approximation I usually use is like this:

Scale the video so that it fits inside 853x480 to get the vertical resolution. Use that vertical resolution and resize to 704x[number]. AddBorders to put the frame size back to 720x480.

AviSynth supports basic integer/float arithmetic, so you could code a trivial function for this.

demistate
4th August 2009, 02:02
I'd like to do the scaling within Avisynth, since Premiere Pro CS3's scaler isn't that great.

thewebchat
4th August 2009, 02:36
function BlogResize(clip input) {
ox = input.width
oy = input.height
ny = oy/(ox/704*40/33)
ny_m2 = int(round(ny/2.0)*2)
pad_y = (480-ny_m2)/2
Spline36Resize(input,704,ny_m2)
AddBorders(8,pad_y,8,pad_y)
}

Gavino
4th August 2009, 08:44
ox = input.width
oy = input.height
ny = oy/(ox/704*40/33)
...
Argh - the dreaded integer division gotcha, which always comes up in aspect ratio conversions.

Needs to be:
ox = float(input.width)
oy = float(input.height)

Alex_ander
4th August 2009, 09:45
If I understand you right, your film is planned to be wider than 16:9 (1920/713=2.69) and you want to crop it from 16:9 for this. Otherwise (in case 16:9 -> 16:9) you'd simply resize it to DVD resolution and encode with 16:9 AR flag.
Since your original 1280x1080 footage corresponds to a 16:9 displayed image, it should occupy 704x480 pixels (with 8+8 borders) stored on DVD. The image height for your new 2.69 AR will be ~320 (317 from simple proportion between the 2 AR's). So here's a solution for resizing and hiding top/bottom (for encoding as 16:9 anamorphic):

Spline36Resize(704,480).Letterbox(80,80).AddBorders(8,0,8,0)

You'll probably need to bob-deinterlace your source before resizing (e.g. with LeakKernelDeint plugin), then re-interlace if you want to keep it interlaced.

thewebchat
4th August 2009, 16:25
Argh - the dreaded integer division gotcha, which always comes up in aspect ratio conversions.

Needs to be:
ox = float(input.width)
oy = float(input.height)

I don't see why this matters? Integer division is rounded, isn't it? And the result needs to be forced to mod2 anyways so I can't imagine that the error is significant at all.

Edit: Never mind, I see it now.

Gavino
4th August 2009, 16:58
Integer division is rounded, isn't it?
No, it's truncated, eg 1280/704 = 1