Resizing DVD-Video To Square Pixels

Resizing Step By Step

In order to resize we'll be using AviSynth. Although there are cropping and resizing filters available with most MPEG-4 encoders, AviSynth is generally more flexible and also has the ability to add borders, which not all tools are capable of. You should generally be able to open an AviSynth script with any program that can open Windows AVI files. If you can't open them with your particular application you can either use ffdshow's MakeAVIS utility to create a fake AVI file or create a real AVI file using a lossless codec like HuffYUV. You can find more information about using AviSynth in our guide on Using AviSynth 2.5. There's a section dedicated to the filters we'll be using for cropping and adding borders as well as one on resizing filters. You'll also want to use DGIndex to help AviSynth read your original DVD files. You can find detailed instructions for Using DGIndex from our guide on the subject.

You'll need to create a DGIndex project (D2V) file and use MPEG2Source in AviSynth to load it. For my examples I'll be using the AvsP AviSynth editor, both for its advanced scripting interface and its built in video preview. If you prefer you can simply your scripts in a text editor and open them with VirtualDub to preview. If your not experienced with AviSynth you should make sure to give our guide on that program, AvsP - AviSynth Made Easy, to find instructions for performing pretty much every operation in this guide.

Step 1 - Examine your DVD Source

Among other things, you'll need to know if your video is interlaced or progressive. If it's originally from a film source it should either be progressive (Force Film in DGIndex) or telecined, requiring IVTC. Make sure you don't leave film sources interlaced (telecined) or else the quality of your final encode will suffer. You can find more information about IVTC in our Digital Video Fundamentals guide on the subject. If you're resizing true interlaced video you'll need to separate it into separate fields first. Otherwise you'll essentially end up with the equivalent of poorly deinterlaced video. Read more about working with interlaced video, including separating fields in the section of our AviSynth 2.5 guide on Basic Interlace Filters. Keep in mind that when resizing separated fields you should reduce all horizontal values by half to match a single field. When you're done the top and bottom fields will be recombined into interlaced frames with the correct dimensions.

If you have 4:3 video you'll want to see if there are borders on either the left or right. Generally there shouldn't be any on the top or bottom, but look to make sure. If your video is widescreen the main thing you'll be looking for is borders on the sides. For many widescreen movies there will also be borders on the top and bottom because while all widescreen (anamorphic) DVDs are 16:9, the movies themselves are often wider than that. If you're using AvsP you can view the video with the F5 key on your keybaord.

The image to the left is from a 4:3 DVD frame with a black border on the left side. The one on the right is from a widescreen (2.35:1) DVD with letterbox borders on the top and bottom, as well as a border to the left.

Step 2 - Crop Borders

Once you've identified the borders you want to remove them. This is done with AviSynth's Crop filter. You can use AvsP's sCrop Editor on the Video menu to set the number of pixels to trim from each side.

The white borders in the frame are where AvsP has removed borders.

Step 3 - Resize

AvsP has a Resize Calculator that can not only help you find the right resolution, but also insert the appropriate line in your AviSynth filter so you don't have to do it yourself. By default the Resize Calculator tries to achieve mod16 resolutions for encoding (16x16 blocks). If you prefer to have more granular control over AR you can configure the calculator to allow resolutions divisible by 2 and manually add borders. If you want to resize to less than 50% of the original resolution or more than 150% you'll need to adjust this as well.


Step 4 - Add Borders (Optional)

If you haven't resized to a mod16 resolution your video can't be encoded yet. You may end up with a non-mod16 resolution if you've chosen smaller resize steps or more accurate AR retention. Use The AddBorders filter to increase the resolution to one compatible with MPEG encoding. Although you can technically add any number of lines to the top or bottom (or sides) of a frame, remember that the black borders are just solid lines/surfaces to your video encoder, and keeping the borders all on one side will tend to make it slightly easier to encode.

To determine the numbers to use for the AddBorders filter you simply need to divide the vertical (or horizontal) resolution by 16. If the result isn't a whole number you need to add borders. For example, if your final resolution is 640x266 the horizontal resolution is fine because 640 is divisible by 16. But 266 divided by 16 results in 16.625. Rounding up to 17 gives me a resolution of 640x272 (17 x 16), requiring 6 pixels to be added to the top or bottom. I typically add to the bottom first, but either one would be fine.

The Script

My final script looks like this:
MPEG2Source("D:\Storage4\DVD\FullDisc\BUCKAROO\VIDEO_TS\Buckaroo Banzai.d2v", cpu=0)
TFM(d2v="D:\Storage4\DVD\FullDisc\BUCKAROO\VIDEO_TS\Buckaroo Banzai.d2v")
TDecimate()
Crop(8, 58, -0, -64)
LanczosResize(640, 272)


Standard Definition TV

While the procedures outlined previously work well if you're encoding video for viewing on a computer monitor, things can get a little more complex if you're playing your video on a MPEG-4 capable DVD player and an analog (SD) TV. The number of variables, ranging the player to the connection to the TV increases substantially. Next we'll look at determining what resolution to use for your DVD player and TV.

Next: Determining The Overscan of an NTSC TV




Table of Contents

  1. Introduction
  2. Basic Resizing
  3. Step By Step
  4. Square Pixels For NTSC TVs
  5. Resizing For SDTV
Advertisement - News comments available below the ad

© 2024 AfterDawn Oy

Hosted by
Powered by UpCloud