Help With Send2HandBrake Script & Interlaced Video

Jep wrote on 9/19/2017, 1:07 AM

I'm using Vegas Pro 13 64bit on a Windows 7 64bit PC, and I have very little knowledge when it comes to scripting.

I use Send2HandBrake to make smooth slow motion mp4 clips. I adapted the Send2HandBrake vegas.avs script using a script I found for generating slow motion clips by frameserving to VirtualDub. It works pretty well where the original video is in progressive format, only occasionally showing artifacts at the edges of fast moving objects. My adapted script is as follows:

OpenDMLSource ("C:\frameserver\source\vegas.avi")
AssumeFrameBased ()
Trim (0, FrameCount-1-Floor(FrameRate))
ConvertToYUY2 (matrix="rec709")
ColorYUV (levels="TV->PC")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mvtools2\mvtools2.dll")


# MSuper gets the clip and prepares it for subsequent operations
#  pel=2 defines the accuracy of motion estimation "2" indicates 1/2 pixel

super = MSuper(pel=2)

# MAnalyse will Get prepared multilevel super clip, estimate motion
# The following two lines specify a forward & backward search of images.
backward_vec = MAnalyse(super, overlap=4, isb = true, search=3)
forward_vec = MAnalyse(super, overlap=4, isb = false, search=3)


MFlowFps(super, backward_vec, forward_vec, num=4*FramerateNumerator(last),den=FramerateDenominator(last))

assumefps(29.97)

However results where the original video is interlaced are very poor, showing a lot of artifacts/pixelation where there is even moderate movement.

I'm wondering if there is anything I can do to adapt my script so that it will work with interlaced video, or perhaps there are some settings that might be tweaked within Vegas prior to frameserving to Handbrake that would solve the problem.

There is another script out there for frameserving interlaced video to VirtualDub. I tried to adapt it in a similar way but couldn't get it to work with Send2HandBrake. It does a good job with VirtualDub but that limits output to .avi and outdated codecs.

Any help with this would be much appreciated.

TIA

Comments

Nigel wrote on 9/19/2017, 5:39 AM

De-interlace in Vegas first.

In Vegas Pro 13, you can use the free plugin: Yadif Deinterlace for Sony Vegas.

That will feed progressive video out of Vegas to Send2HandBrake.

http://www.yohng.com/software/yadifvegas.html

NickHope wrote on 9/19/2017, 9:58 AM

That's good advice from Nigel, but if you want to get fancy you could also do the deinterlacing with QTGMC at the same time as the slomo in AviSynth, which should look even better. Here is an example script, leaving the first 6 lines of your script unchanged:

OpenDMLSource ("C:\frameserver\source\vegas.avi")
AssumeFrameBased ()
Trim (0, FrameCount-1-Floor(FrameRate))
ConvertToYUY2 (matrix="rec709")
ColorYUV (levels="TV->PC")
loadplugin("C:\Program Files (x86)\AviSynth 2.5\plugins\mvtools2\mvtools2.dll")
QTGMC(SubPel=2)
super = MSuper(pel=2)
MFlowFps(super, QTGMC_bVec1, QTGMC_fVec1, num=2*FramerateNumerator(last), den=FramerateDenominator(last))
AssumeFPS(29.97)

You would need QTGMC and it's core plugins from http://avisynth.nl/index.php/QTGMC and you'd probably be better auto-loading them by putting them in C:\Program Files (x86)\AviSynth\plugins\

I haven't tested that exact script. On my system I tested it with AviSynth+ x86 and VirtualDub Filtermod x86 by using this modification of that script which fits my typical workflow:

SetMemoryMax(3072)
AviSource("d:\fs.avi")
AssumeTFF()
ConvertToYV12(interlaced=true)
QTGMC(SubPel=2)
super = MSuper(pel=2)
MFlowFps(super, QTGMC_bVec1, QTGMC_fVec1, num=2*FramerateNumerator(last), den=FramerateDenominator(last))
AssumeFPS(29.97)
Prefetch(10)
Nigel wrote on 9/19/2017, 4:20 PM

I agree with Nick.

Yadif is quicker/easier/faster-render solution. Very good quality.

Avisynth is more complex. Slower-render. Excellent quality.

 

Jep wrote on 9/21/2017, 8:25 PM

Nigel & Nick,

Thank you both for your replies and suggestions. Sorry for late reply but I've been away for a couple of days.

I've just tried a quick test with the Yadif deinterlacer for Vegas. It worked very nicely if not quite as well as slowing down progressive video. My test had a shot of a hand moving across the screen at moderate speed. The tips of the fingers tended to break up a bit, but everything else was very smooth indeed.

I would very much like to give the QTGMC option a try. I've downloaded the following zip files:

QTGMC 3.357.7z

masktools2-v2.2.10.7z

NNEDI3_v0_9_4_47.7z

RgTools-0.96.7z

SMDegrain v.3.1.2d.zip

Am I correct in thinking that I unpack those and copy the contents to C:\Program Files (x86)\AviSynth\plugins\.???

Also I already have mvtools installed on my PC so I presume I don't have to install the version shown on the QTGMC list of "Core Plugins & Scripts"..

Again - many thanks for your help and advice.

NickHope wrote on 9/22/2017, 12:26 AM
Am I correct in thinking that I unpack those and copy the contents to C:\Program Files (x86)\AviSynth\plugins\.???

Just copy over the .avsi and .dll files, not the whole contents.

The masktools version you want for x86 usage is masktools2-v2.2.10.7z\x86\masktools2.dll

I would update to pinterf's latest MvTools from here. He's been fixing and optimizing it a lot.

If you want to go further with this stuff outside of a Send2HandBrake workflow then I recommend using pinterf's AviSynth+ and rendering in VirtualDub FilterMod. For frameserving you'll need to use the x86 versions. If you render from a file without frameserving then you can use the x64 versions. The easiest way to install and uninstall AviSynth versions is Groucho's universal installer, and that has the benefit that you can use different folders that are not in your C:\Program Files folders.

I have a very old Vegas>QTGMC tutorial here. It's way out of date but still has some useful tips and might contain something that helps you if things don't go smoothly.

Jep wrote on 9/22/2017, 9:43 PM
Am I correct in thinking that I unpack those and copy the contents to C:\Program Files (x86)\AviSynth\plugins\.???

Just copy over the .avsi and .dll files, not the whole contents.

The masktools version you want for x86 usage is masktools2-v2.2.10.7z\x86\masktools2.dll

I would update to pinterf's latest MvTools from here. He's been fixing and optimizing it a lot.

If you want to go further with this stuff outside of a Send2HandBrake workflow then I recommend using pinterf's AviSynth+ and rendering in VirtualDub FilterMod. For frameserving you'll need to use the x86 versions. If you render from a file without frameserving then you can use the x64 versions. The easiest way to install and uninstall AviSynth versions is Groucho's universal installer, and that has the benefit that you can use different folders that are not in your C:\Program Files folders.

I have a very old Vegas>QTGMC tutorial here. It's way out of date but still has some useful tips and might contain something that helps you if things don't go smoothly.

Thanks again Nick. I think I've got QTGMC working with Send2Handbrake. I went to your old Vegas>QTGMC tutorial and downloaded QTGMC and the Plugin package from the -Vit- Doon9 thread you had linked there. It seemed the easiest thing to do as everything is in the one place and includes instruction texts in the download folders.

Initially the results were pretty horrible. The output slomos vere very choppy and featured a weird forward/backward jitter making them unusable. I played around with a lot of settings. Eventually I went in to Project Properties in Vegas and set Field Order to None (progressive scan). That seems to have done the trick - though I'm not sure if I'm was supposed to do that. It resulted in smooth slow motion with the only complaint being those moving fingers that were breaking up with Yadif looked a bit out of focus where they were moving fastest. Nevertheless a distinct improvement over Yadif.

I'm wonder if updating everything would improve results. So for instance - I'm on Avisynth 2.5 and I could upgrade that to 2.6. Similarly I could also update to the latest QTGMC + Plugins, and pinterfs MVTools as you suggested. Do you think that might help quality?

Lastly, the only downside I see to using QTGMC is the render times. It seems to be exceptionally slow. My test renders were 162 frames long as indicated by Vegas Absolute Frames time format. Handbrake said it was achieving an average of 1.1fps but I think it was much slower than that as it was taking almost 7.5 minutes to complete the render. That's 7.5 minutes to render just over 5 seconds of video!!!

Unless I can find a way to speed up the render I probably won't have much use for Send2Handbrake + QTGMC.

Many thanks again for your direction and help. Very much appreciated.

NickHope wrote on 9/22/2017, 11:20 PM

Field order should be an interlaced format (probably top field first for HD) and you should render from Vegas as interlaced. QTGMC will still make an attempt at "smoothing things out" even if you render from Vegas as progressive, but it's not the way it's supposed to work at all. You should of course not have Yadif applied to the footage in Vegas if you are going to do the deinterlacing with QTGMC.

I always use up-to-date versions of the various tools. They have been developed a lot since Vit posted his packages and because there are fewer developers involved in the latest versions (mostly pinterf at the moment), they tend to work better together.

For speed, yes QTGMC is generally slow. To speed it up you need to get into setting the multi-threading and memory settings referred to in the "speeding things up" section of my old tutorial. It makes a big difference. You'll need an AviSynth MT build or preferably AviSynth+. Note that these things are set differently in AviSynth+ scripts than they are in AviSynth, but the current development is all on AviSynth+ and I think it's worth getting into that if it can be made to work in your workflow.

64-bit helps speed/stability too, and nearly every filter you'd want is now supported for that, but you can't use that if you're frameserving because the frameserver is only 32-bit (actually there may be workarounds for that using other tools but it's complex).

Also the fast, faster, very fast and super fast QTGMC presets can still give great results. When you get to ultra fast it switches to Yadif with a bit of extra processing so that's not so beneficial over the Vegas Yadif plugin.