logo Sign In

Avisynth 4:3 NTSC -> anamorphic NTSC

Author
Time

I saw there was another upscaling thread, but that was focused on HD upscales and rather than derail that one I thought I'd start my own.

I'd like to convert a 4:3 letterboxed DVD to 16:9 anamorphic (all NTSC).  That part is simple enough, but I'd like to retain as much quality as possible and I don't mind a slow script, i.e. use various deinterlacing/scaling tricks to avoid jaggies.

Does anyone have any generic scripts that would be handy to start with?  I'm pretty new to avisynth, so verbose is good.

Project Threepio (Star Wars OOT subtitles)

Author
Time
 (Edited)

I'm having some luck in testing with the following script.  Feel free to critique; I'm new to all of this.  I haven't actually converted a real video yet.

import("TempGaussMC_beta1.avs")

directshowsource("input.m2v")

# crop top and bottom from the 4:3 frame
crop(0,72,0,-72)

# stabilized deinterlace (also doubles frames, so we undo that with selecteven)
converttoyv12(interlaced=true)
tempgaussmc_beta1()
selecteven()
converttoyuy2()

# scale image 2x vertically, interpolating missing fields (slow)
eedi2()

# stretch to anamorphic ntsc frame
spline36resize(720,480)

# compensate for the blurring effect from all of this resizing
sharpen(0.25)

# interlace the video
bob(0.0, 1.0)

# set NTSC video framerate
assumefps("ntsc_video")

EDIT: Script fixes.

Project Threepio (Star Wars OOT subtitles)

Author
Time

CatBus said:

I'd like to convert a 4:3 letterboxed DVD to 16:9 anamorphic (all NTSC). 

Commercial and professional NTSC DVD releases from film (movies & TV) are 24fps 720x480 on disc, with flags to instruct the player how to show it:

* The pull-down flag is for 24fps to telecine it to 30fps for television.
* The anamorphic flag is for anamorphic DVDs (which you are trying to make here) to stretch the width for a 16:9 "widecreen" TV, or to squash the height for a 4:3 "standard" TV.

These flags can be set in your DVD authoring software. Nothing more needs be done -- the player handles it from there.

You are working on the full frame. There is no need to process fields of the DVD-extracted source for this conversion. Aside from any noise reduction or edge enhancement or color/levels correction, your basic script need only be your original script with the field-functions removed:

import("TempGaussMC_beta1.avs")

directshowsource("input.m2v")

# crop top and bottom from the 4:3 frame
crop(0,72,0,-72)

# stretch to anamorphic ntsc frame
spline36resize(720,480)

You might want to experiment where in your script to clean/adjust the picture as cropping and resizing also affect the end result.

And keep ConvertTo calls to a minimum. Multiple converting between color-spaces distorts the color. Be mindful, too, of how ConvertTo's "matrix coefficients" affect the image (see Avisynth docs for the function description).

BTW, your cropping should be 60 lines for top and bottom instead of 72:

4:3 is 1.33 ratio for TV (but the display is different between PC and TV).
4:3 is 1.5 ratio for PC (720x480).
16:9 is 1.78 ratio for TV.
16:9 is 2.0 ratio for PC (720x360)
The vertical difference is 480-360=120, which is divided in half for top and bottom -- crop(0,60,0,-60).

So, on this letterboxed frame from the 2010 DVD,

the cropping removes 60 lines on top and 60 lines on bottom

and resizing the resulting 720x360 back to full 720x480

creates an anamorphic image ready for the DVD anamorphic flag for proper display on both standard and widescreen TVs.

Author
Time
 (Edited)

Thanks for the catch on cropping!  I think I got those 72 values by working with a PAL source, and forgot to change them for NTSC...

Yeah, I hate having to do the convertto's, but tempgaussmc_beta1() only works in yv12, and I really like its deinterlacing results.  Deinterlacing/interpolated scale/reinterlacing seems to produce a less aliased image than the basic script, which IMO looks better, but yes, it certainly makes things a lot more complicated (and slower) than just scaling the image.

EDIT: Wait, I think I got what you were saying about having the full frame and not messing with the fields.  I thought crappy old 4:3 letterboxed DVDs would be hard-telecined, but maybe they just have the pulldown flag just like modern DVDs...  I'll try the whole process without deinterlacing/interlacing, but still using the interpolated scale, and report back.

Project Threepio (Star Wars OOT subtitles)

Author
Time
 (Edited)

CatBus said:

I thought crappy old 4:3 letterboxed DVDs would be hard-telecined, but maybe they just have the pulldown flag just like modern DVDs.

Unfortunately for the buying public, hard-letterboxed DVDs aren't an age issue, but are a shoveling-slop-to-the-hogs one.

It's easy to tell native from telecined. Just check any fair amount of movement, like in this comparison of the DVD (24fps) to a broadcast (30fps), again from 2010:

The overlapped-frame fields of 30fps is always distinctive.

Author
Time

CatBus said:

I thought crappy old 4:3 letterboxed DVDs would be hard-telecined, but maybe they just have the pulldown flag just like modern DVDs...  I'll try the whole process without deinterlacing/interlacing, but still using the interpolated scale, and report back.

Even if the video is 29.97 fps hard-telecined, performing IVTC is the correct solution, it should never be deinterlaced.

Guidelines for post content and general behaviour: read announcement here

Max. allowable image sizes in signatures: reminder here

Author
Time

Thanks for the help so far... running into a snag.  HCenc (GUI) is only encoding about 75% of the video, even though it says it's doing all frames and it completed successfully.  I play the AVS through Windows Media Player and the whole thing plays all the way to the end.  75% is suspiciously close to 24/30, so I'm wondering if it's a framerate problem.

I've been trying to use an m2v file extracted from a VOB file as my source, but I'm wondering if it wouldn't be better to just use the VOB as the source.  Perhaps by not using the VOB, I'm losing some framerate/other hints that would help out the encoder.  Any other suggestions welcome.

Project Threepio (Star Wars OOT subtitles)

Author
Time

That seems to be the issue.  The VOB file shows a length of 1:31:55, the extracted m2v shows a length of 55:11, and that's exactly where it truncates.  Rather than trying to get the script to see the correct length on the m2v (probably some framerate screwup in directshowsource(), I'll just use the VOB.  It's easier in the long term anyway.

Project Threepio (Star Wars OOT subtitles)

Author
Time

Personally, I always use DGIndex and MPEG2Source() instead of DirectShowSource(). Guess I'm just old school.

Guidelines for post content and general behaviour: read announcement here

Max. allowable image sizes in signatures: reminder here

Author
Time
 (Edited)

Just to update, I'm having much better success now, but still running into snags.  Using DGIndex and MPEG2Source per Moth3r's advice after more DirectShowSource problems, and now I'm seeing that in fact it's MOSTLY progressive with a few noticeably interlaced bits (ugh), so I'm now trying TIVTC and hoping for better-looking results.  So far, so good, but slow...

EDIT: Did I mention I'm trying this on a Hong Kong film?  Apparently crappy telecines are kindof a thing there.  Who knew?  Latest script below:

loadplugin("dgdecode.dll")
loadplugin("eedi2.dll")
loadplugin("tivtc.dll")

# d2v file created from vob file by dgindex
mpeg2source("input.d2v")

# inverse telecine to reconstruct progressive frames
tfm(d2v="input.d2v")
tdecimate()

# crop top and bottom from the 4:3 frame (60px top & bottom on a perfectly centered image)
crop(0,60,0,-60)

# scale image 2x vertically, interpolating missing fields (slow)
eedi2()

# resize to anamorphic ntsc frame
spline36resize(720,480)

Project Threepio (Star Wars OOT subtitles)

Author
Time

That last script did it!  It may not have done perfect IVTC on those problem sections, but I don't see anything obvious anymore.  Thanks to everyone for the help!

Project Threepio (Star Wars OOT subtitles)