Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 1st May 2011, 09:35   #1  |  Link
nhope
partially-informed layman
 
Join Date: Jan 2002
Location: Bangkok, Thailand
Posts: 314
1080-60i to 480i DVD test renders

Further to much recent debate on ways to improve interlaced HD>SD downscaling for DVD, I set up a minute's project of various 60i HD footage and converted it to SD NTSC MPEG-2 in a variety of ways. I have put 4 of my renders into a ready-to-burn DVD project which you can download here (193 MB).

Settings:
Sony Vegas Pro 10.0c.
Full-resolution rendering quality: "Best".
Deinterlace method: "Interpolate".
Color Curves and Levels applied to video events.
Events conformed to 16-235 (broadcast-legal) levels.
"Reduce interlace flicker" switch: OFF.
No blur or sharpen applied in Vegas Pro.
Debugmode Frameserver 2.10
AviSynth 2.5.8 single-threaded used in tests 2 and 3.
All encoded in CCE Basic at 8000 kbps 1-pass CBR, upper field first.
The Belle Nuit test chart is the 1920x1080 version from here.

Test 1 - Rendering time 309 seconds (100%)
Demonstrates Vegas Pro resizing without blurring or sharpening.
HD clips in NTSC widescreen project, modified with upper field first and PAR 1.1852.
Frameserved in RGB24.

Test 2 - Rendering time 431 seconds (139%)
Demonstrates AviSynth "IResize" function developed by Gavino, IanB and others.
Script does low-pass filter "automatically" during resizing to reduce twitter/shimmer/aliasing etc..
HD clips in 1080-60i project.
Frameserved in YUY2 (slightly faster than RGB24).
AviSynth Script:
Code:
source=AviSource("d:\fs.avi").ColorYUV(levels="TV->PC").AssumeTFF  #Expands levels if frameserved in YUY2
IResize(source,720,480)
function IResize(clip Clip, int NewWidth, int NewHeight) {
  Clip
  SeparateFields() 
  Shift=(GetParity() ? -0.25 : 0.25) * (Height()/Float(NewHeight/2)-1.0)
  E  = SelectEven().Spline36resize(NewWidth, NewHeight/2, 0,    Shift)
  O  = SelectOdd( ).Spline36resize(NewWidth, NewHeight/2, 0,   -Shift)
  Ec = SelectEven().Spline36Resize(NewWidth, NewHeight/2, 0,  2*Shift)
  Oc = SelectOdd( ).Spline36Resize(NewWidth, NewHeight/2, 0, -2*shift)
  Interleave(E, O)
  IsYV12() ? MergeChroma(Interleave(Ec, Oc)) : Last
  Weave()
}
Test 3 - Rendering time 1504 secs (486% - multi-threaded would be much faster)
Demonstrates more advanced method adapted from a suggestion by Didée.
HD clips in 1080-60i project.
Frameserved in YUY2 (RGB not supported by script).
High quality Bob using TDeint.
Resizing by sequential bicubic passes.
Smoothing with QTGMC.
Sequential blur and sharpen filters.
AviSynth Script:
Code:
AviSource("d:\fs.avi")
ColorYUV(levels="TV->PC") #Expands levels if frameserved in YUY2
AssumeTFF
TDeint(mode=1)
bicubicresize(1440,960)
bicubicresize(720,960,-.8,.6)
p1 = bicubicresize(720,480,-.8,.6)
p2 = p1.QTGMC(TR0=1,TR1=1,TR2=2,InputType=1)
p2.blur(0,1).sharpen(0,.51).blur(0,1).sharpen(0,.85)
i1 = assumetff().separatefields().selectevery(4,0,3).weave()
# p1 # straight to 60p
# p2 # plus more calmed
  i1 # re-interlaced p2
return(last)
Test 4 - Total Rendering time 1822 secs (589%)
Demonstrates down-converting of HDV to DV in my Sony Z1P camera.
HD clips in 1080-60i project.
Render to HDV (quality 31)
Down-convert to DV in Sony Z1P camera.

If you have the time and inclination, please burn the 2 folders to a DVD and let me know any reactions/preferences you have to it, and please tell us what gear you watched it on (CRT, LCD, DVD software etc.).

Also please let me know if I have correctly described what the scripts in tests 2 and 3 are actually doing.

There is another thread with feedback about this on the Vegas forum here, but I think you would have to own Sony software to contribute.

Thanks to everyone who allowed me to use and upload footage.
nhope is offline   Reply With Quote
Old 3rd May 2011, 21:07   #2  |  Link
javlak
Registered User
 
Join Date: Mar 2011
Posts: 48
Hi there. Just a couple of remarks.

a) I suppose you set the deinterlace method of Sony Vegas to None and the field order to progressive when you use the avisynth deinterlacers but you forgot to mention it?
b) Disabling the resampling of Sony Vegas (default is Smart Resample iirc) can also increase the picture quality in some cases, as Smart Resampling can introduce blurriness, maybe you should use that as well?
javlak is offline   Reply With Quote
Old 4th May 2011, 10:46   #3  |  Link
nhope
partially-informed layman
 
Join Date: Jan 2002
Location: Bangkok, Thailand
Posts: 314
Quote:
Originally Posted by javlak View Post
Hi there. Just a couple of remarks.

a) I suppose you set the deinterlace method of Sony Vegas to None and the field order to progressive when you use the avisynth deinterlacers but you forgot to mention it?
No, that would have deinterlaced the video before it reached the AviSynth deinterlacers.

Quote:
b) Disabling the resampling of Sony Vegas (default is Smart Resample iirc) can also increase the picture quality in some cases, as Smart Resampling can introduce blurriness, maybe you should use that as well?
The resample setting should make no difference because there is no change in frame rate.
nhope is offline   Reply With Quote
Old 4th May 2011, 14:17   #4  |  Link
javlak
Registered User
 
Join Date: Mar 2011
Posts: 48
Quote:
Originally Posted by nhope View Post
No, that would have deinterlaced the video before it reached the AviSynth deinterlacers.
Not if you set the Field Order to None... It doesn't make a difference really, just best practice I guess.


Quote:
Originally Posted by nhope View Post
The resample setting should make no difference because there is no change in frame rate.
Indeed. Again, I only use it as best practice and that's the only way I meant it (although I am aware that some people prefer blurriness to choppiness).
javlak is offline   Reply With Quote
Old 13th May 2011, 03:56   #5  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
What about:

avisource("some_1080_60i.avi")
assumetff()
bob(0.3782,0.3109) # Robidoux filter is mathematically optimized for cylindrical resizers (which are painfully slow)
spline36resize(704,480).addborders(8,0,8,0,align=true) # maintain a better NTSC 16:9 aspect ratio
ColorYUV(levels="TV->PC")
separatefields()
selectevery(4,0,3)
weave()
henryho_hk is offline   Reply With Quote
Old 13th May 2011, 05:56   #6  |  Link
nhope
partially-informed layman
 
Join Date: Jan 2002
Location: Bangkok, Thailand
Posts: 314
Interesting stuff Henry. I'll try it out. At the moment I'm using:

AviSource("some_1080_60i.avi")
ColorYUV(levels="TV->PC")
AssumeTFF
LanczosResize(720,height)
TDeint(mode=1)
LanczosResize(width,480)
blur(0.0,1.0)
sharpen(0.0,0.75) # adjust 2nd value between 0.5 and 1.0 to taste
assumetff()
separatefields()
SelectEvery(4,0,3)
Weave()

One thing that interests me is that TDeint(mode=1) gives a very different bob to other methods. If you bob a 1920x1080 Belle Nuit test card it gives you smooth grey in the area of alternating black/white horizontal 1px lines, whereas Bob(), Yadif(mode=1) and QTGMC(sharpness=0) all give alternating black and white frames. I'm not sure which is preferable in an HD>DVD scenario.
nhope is offline   Reply With Quote
Old 13th May 2011, 11:19   #7  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
I apply ColorYUV() later so that it can deal with less data. Yet, I do not apply a horizontal resizer first because bob() is pretty fast and I also want to leave more data for spline36resize() to help hiding the jagginess of slant edges.

And I do suggest looking more into the aspect ratio correction.

Technically, if we have an image of alternating black/white horizontal 1px lines, we really don't know whether it is a static picture of black/white lines or two alternate black/white pictures. Nevertheless, it is weird to produce a grey picture. Perhaps TDeint() has applied some vertical filtering beforehand. Let me try tonight what QTGMC(border=true) will produce.
henryho_hk is offline   Reply With Quote
Old 13th May 2011, 12:09   #8  |  Link
nhope
partially-informed layman
 
Join Date: Jan 2002
Location: Bangkok, Thailand
Posts: 314
My thinking was to apply ColorYUV earlier so that the bobbing/resizing/filtering has more dynamic range (a little more contrast) to work with. But I didn't really see a difference in the quality of the output. Ideally I would prefer to use SmoothLevels in the same place in the script that you have ColorYUV, but it doesn't support YUY2 and YV12 gives me a chroma error

I've read a number of times about a slight speed increase from doing the horizontal resize before deinterlacing, but if there's a good reason not to do that then I'll change. Also it seems like most of the experienced AviSynth users prefer Spline36 resize over Lanczos3. I might swap to that, although I couldn't really see any difference in the result.

Won't 704x480 + addborders give slight letterboxing (EDIT: I meant pillarboxing)? I'd prefer to avoid that if possible. Not a problem with CRT overscan but it would show up in DVD software, wouldn't it?

Finally I tend to agree that the TDeint bob is slightly weird to produce a grey picture in the 1px area. Maybe it's related to its motion adaptivity. However I get the feeling that might be a happy accident that actually helps reduce twitter/flicker/shimmer in the DVD. The downscaled output from that looks good.

By the way, the "very fast" QTGMC seems to be good enough for applying to HD in this workflow.

Last edited by nhope; 5th July 2011 at 07:47. Reason: note re pillarboxing
nhope is offline   Reply With Quote
Old 14th May 2011, 16:03   #9  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Letterboxing is unavoidable because NTSC 16:9 DVD is really "wider" than 1920x1080 HD.
henryho_hk is offline   Reply With Quote
Old 14th May 2011, 16:43   #10  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,496
Quote:
Originally Posted by henryho_hk View Post
Letterboxing is unavoidable because NTSC 16:9 DVD is really "wider" than 1920x1080 HD.
But any correct playback implementation should discard the outermost 8 pixels on either side and use only the central 704x480 when displaying the output.

Or you can just render to DVD straight from 704x480.

David
wonkey_monkey is offline   Reply With Quote
Old 15th May 2011, 17:40   #11  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Yes, 704x480 is a valid DVD resolution too.
henryho_hk is offline   Reply With Quote
Old 5th July 2011, 16:53   #12  |  Link
nhope
partially-informed layman
 
Join Date: Jan 2002
Location: Bangkok, Thailand
Posts: 314
Quote:
Originally Posted by henryho_hk View Post
I do not apply a horizontal resizer first because bob() is pretty fast and I also want to leave more data for spline36resize() to help hiding the jagginess of slant edges
I'm puzzled by this. I thought AviSynth resizers work in 2 separate passes, so it wouldn't make any difference to the result to do the horizontal resize before a bob and the vertical resize after But I do see very small differences in the result... I think.

Also there seems to be an error with addborders(8,0,8,0,align=true) in your script. align=true works for crop but doesn't seem to be a valid option for addborders. It works OK without that option.
nhope is offline   Reply With Quote
Old 6th July 2011, 01:06   #13  |  Link
henryho_hk
Registered User
 
Join Date: Mar 2004
Posts: 889
Yup, I was just writing the script on scratch on the forum and so I put the ",align=true" incorrectly.

By "leaving more data to bob()", I mean "spline36resize(704,last.height).bob(0.3782,0.3109).spline36resize(704,480)" vs "bob(0.3782,0.3109).spline36resize(704,480)". I am trying to leave more horizontal data to bob(), and then hide the imperfection of bob()'s field-interpolation by the final shrink. Of course, if the video is grainy, you may try shrinking horizontally first, then feed the "hopefully-cleaner" data into bob() for field-interpolation, hoping for better result.
henryho_hk is offline   Reply With Quote
Old 6th July 2011, 10:48   #14  |  Link
2Bdecided
Registered User
 
Join Date: Dec 2002
Location: UK
Posts: 1,673
dumb bob is a linear operation (as is resizing!), so I can't see why the order matters at all. Except for tiny rounding differences maybe?

The various smart bobs aren't linear at all, so difference between resizing before vs after are somewhat unpredictable - except for the speed advantage.

Cheers,
David.
2Bdecided is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 15:04.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.