OT: Tutorial on creating Slo-Mo using AVISynth

johnmeyer schrieb am 07.12.2010 um 02:43 Uhr
I created a "quick & dirty" tutorial for how to create slow motion from interlaced video using two instances of Vegas, Debugmode's Frameserver, AVISynth, VFAPIConv, and a slow motion script that uses a free motion estimation plug-in called MVTools2.

It may sound complicated, but the tutorial is only three minutes long, and it takes a lot less time than that to actually create the video once the various free tools have been downloaded and installed.



Here's one of two scripts that I use for interlaced video slow motion:

loadplugin("C:\Program Files\AviSynth 2.5\plugins\MVTools\mvtools2.dll") 

source=AVISource("E:\frameserver.avi").KillAudio().assumetff()

final=ApplyInterlacedFilter(source,"SlowMo").assumefps(29.97,false)

return final


function ApplyInterlacedFilter(clip v1, string filter)
{
v2 = separatefields(v1)
selecteven(v2)
even = Eval(filter)
selectodd(v2)
odd = Eval(filter)
interleave(even,odd)
return weave()
}

function SlowMo(clip thisclip)
{
super = MSuper(thisclip,pel=2)
backward_vectors = MAnalyse(super,blksize=8, overlap=2, isb = true, search=3)
forward_vectors = MAnalyse(super,blksize=8, overlap=2, isb = false, search=3)
# num=60000 produces 50% slow motion; 120000 produces 25% slow motion, etc.
MFlowFps(thisclip,super,backward_vectors, forward_vectors, num=60000, den=1001, ml=100)
}


I have other scripts that operate quite a bit faster, but this one is likely to have the fewest problems.

Kommentare

NickHope schrieb am 07.12.2010 um 02:47 Uhr
Thank you very much John
Jim H schrieb am 07.12.2010 um 21:53 Uhr
Thanks John. I don't understand the need for two instances of vegas and the frame server. What's the logic?
johnmeyer schrieb am 08.12.2010 um 00:02 Uhr
I don't understand the need for two instances of vegas and the frame server. What's the logic? The basic three reasons for frameserving -- whether from Vegas into another application, or back into Vegas are:

1. Avoid multiple renders, with possible loss of quality.
2. Avoid filling up hard drive space with intermediate files.
3. Speed up workflow, both from the reduction in the number of steps required, and also by avoiding massive reads & writes to hard drives, especially if you use uncompressed files to avoid any quality hit.

Frameserving passes each frame, via memory, not hard disk, from one application to another. Thus, each frame of video is served out of Vegas (via the Debugmode frameserver) into the AVISynth script, and once the script has finished its magic, the results of the frame are served out, via VFAPIConv, into the second instance of Vegas, all without any encoding and without any bits being written to or read back from the hard drive.

The final advantage is that when encoding does finally happen (you do eventually have to put the finished video into an AVI or other file), it can be done with the professional encoding codecs supplied with Vegas Pro. While it is true that better codecs exist, unless you want to spend a lot of money (for Sorenson, for instance), you'll be better off using the codecs in Vegas than using shareware codecs (DivX, for instance).


liquid schrieb am 08.12.2010 um 04:45 Uhr
I really don't get anything you just did in your video....guess I"ll have to rewind. You didn't really show the end product either. Too bad as I'm left wondering what the final results looked like.
JackW schrieb am 08.12.2010 um 05:27 Uhr
Thanks very much, John. As always, I appreciate the work you put into solving problems for us in the Forum.

Jack
Grazie schrieb am 08.12.2010 um 05:33 Uhr
John - Thank you.

You are a gent.

Grazie


Grazie

PC 10 64-bit 64gb * Intel Core i9 10900X s2066 * EVGA RTX 3080 XC3 Ultra 10GB - Studio Driver 551.23 * 4x16G CorsVengLPX DDR4 2666C16 * Asus TUF X299 MK 2


Cameras: Canon XF300 + PowerShot SX60HS Bridge

Richard Jones schrieb am 08.12.2010 um 12:28 Uhr
John,

That's excellent. Thank you very much.

Richard
Tom Pauncz schrieb am 08.12.2010 um 14:41 Uhr
That's impressive John.

Do you have a recommended site from which to download VFAPIConv? Founds lots using Google and some seem suspect.

TIA,
Tom

edit: I didn't read it either - watched the vid here. Have it now. :-)
johnmeyer schrieb am 08.12.2010 um 14:52 Uhr
I really don't get anything you just did in your video....guess I"ll have to rewind. You didn't really show the end product either. Too bad as I'm left wondering what the final results looked like. You didn't read the text I provided in the tutorial. That text contains the slo-mo AVISynth script, and contains a live link to another YouTube video which shows the results from two different methods of doing slo-mo in Vegas, along with the results of doing the same slo-mo using the technique described in the tutorial.
rmack350 schrieb am 08.12.2010 um 17:57 Uhr
Unfortunately, the text provided along with the video on the youtube page is folded up and easy to miss. You have to twirl-down the text to see it and then you'll see a link to a sample movie comparing the outputs from Vegas with the AVISynth output.

Also, there are a lot of concepts at work here that some readers may not be familiar with, but take a look at the results video. The output is much, much better than what Vegas does. Once you see it you'll be motivated to figure out things like frameserving and AVISynth.

Start with the results movie:

www.youtube.com/watch?v=UEfpP1zZKVs

Then look at the tutorial:

www.youtube.com/watch?v=M9TJuxo6lNI


Rob Mack

<Edit> yep, those links were totally off. Sorry 'bout that.</edit>
johnmeyer schrieb am 08.12.2010 um 18:39 Uhr
Those links are broken. I'm sure you can go back and fix them, but for those who want to see the results and compare them to what Vegas can do, here is the video I posted quite some time ago which shows a 1.5 second clip that I then slowed way down in Vegas, first using "Smart Resample" and then with resample disabled. At the end of this clip, I show the same 1/8 speed slow motion using the AVISynth/MVTools technique I outlined in the tutorial that is the subject of this thread.



The technique of blending adjacent frames used by Vegas will always produce predictable results, but those results will be blurry, and not entirely smooth, as the video above shows. You can get rid of the blur by disabling resample, but then the slow motion looks like an old-fashioned flipbook.

Slow motion video done with motion estimation (like Twixtor, MVTools, Motionperfect, and various other programs) can look fantastic, but when the algorithms break down, you can end up with some really nasty artifacts.

Obviously the best thing to do is buy a camera which can over-crank, but that is expensive.

If you have the time, what I do is to create the slow motion in Vegas and using MVTools. I then put the MVTools video on the top track. Whenever I spot an artifact I don't like, I create a mask and let the Vegas version of the slow motion show through. The mask must be feathered, it must be keyframed to follow the motion, and it must be turned on and off. To really do it right involves fading the mask in and out, something that takes a fair amount of work. But, I mention this just in case someone is looking for a way to not have to make the choice between the problems created by Vegas slow motion and the problems created by motion estimation. You can, to a large degree, have the best of both worlds, if you are willing to work a little.


crocdoc schrieb am 08.12.2010 um 20:11 Uhr
Thanks very much for taking the time to put that together. Most of it was way beyond my current level of knowledge with Vegas/scripting/plug-ins, but it certainly seems clear enough that when I have the time to download the plug-ins and sit in front of my computer going through it step by step I feel I may be able to manage it.

One question, though - I'll be using 50p rather than 50i to start with, so I presume I'll need a different script since I am working with whole frames rather than fields?

NickHope schrieb am 09.12.2010 um 02:39 Uhr
John, adding a couple of YouTube annotations to the video, one telling viewers to open the description to get the script, and the other containing a live link to your results video, might save you having to field a lot of questions from people who've missed them. Just a thought. YouTube annotations are dead easy to add.
goodrichm schrieb am 09.12.2010 um 21:47 Uhr
Thanks so much John for sharing this wonderful techinique and opening our eyes to a better way!

I'm having a few issues and apologize for the long post. Thanks for any help...MG

-----

I found that in order to have VirtualDub and Avisynth scripts to be recognized by VFAPIconv, you have to copy ReadAVS.dll and ReadAVS.reg to the VFAPIconv dir.

Found out about ReadAVS here:
http://forum.videohelp.com/threads/37390-How-to-frameserve-%28dvd2avi-VirtualDub-Avisynth-VFAPI%29

Download ReadAVS here:
http://avisynth.org/warpenterprises/files/

-----


I'm having problems getting your slo-mo workflow to work on Vegas Pro 10a 32 bit:

1) Vegas render problems:

a) DebugMode Frameserver 2.7 is causing Vegas to crash whenever I hit the save button in "Render As" window. Looks like error crash points to modules vegas100.exe and ntdll.dll. I had no problems with FrameServer before installing VFAPI Reader Codec.
I don't know if running proxyoff.reg, which comes with VirtualDub, as prescribed on Doom9 caused the problem or what. I tried this because VFAPIConv wasn't giving me the option to open up an .AVS script. When I ran proxyoff.reg, the PC complained that not all parameters could be set because they were in use by something else. I tried the proxyon.reg in VD to see if it helps, but now FrameServer only works intermittently without crashing Vegas. When I ran proxyon.reg, I got the same prompt saying all parameters couldn't be set.

b) Now, Vegas won't render to "Video for Windows" if FrameServer was tried previously. I guess because it's still selected in the Render window before trying to change to video for windows format. Vegas 64 bit renders no problems using any option. After test rendering with Vegas 64 and going back to Vegas 32, the renders with FrameServer and Video for Windows (AVI) work okay for a while. Really strange things happening here in render land!

Doom9 article:
http://www.doom9.org/index.html?/mpg/vfapi_reader_codec.htm


2) The output produce by VFAPI Reader isn't readable by any of the programs on my PC i.e. Windows Media Player, Vegas10a, VirtualDUB1.9, TMPGEnc 2.5, etc. See attached images for errors. I think it's the YUY2 video format that's causing the problem. aviSynth seems to be working correctly as VFAPIconv doesn't complain when converting the scripts. I can create the "Version.avs" script and it can be viewed directly in Windows Media Player and TMPGEnc, etc. when not converting thru VFAPIconv.

Is there a particular CODEC needed? If so, can you recommend one?

Please see attached the list of CODECs installed.

Vegas error:
http://www.screencast.com/t/bkr3SDHr

VirtualDub error:
http://www.screencast.com/t/V5BFcIrM8TD

CODECs Installed:
http://www.screencast.com/t/nAMJeyg6


PC Laptop Specs:

HP Pavilion dv6-2190us, Core i7, 4GB RAM
Win7 64bit Home Premium
nVidia Geforce GT230M, 1GB Dedicated RAM

Vegas Pro 10a
DebugMode FrameServer 2.7
VFAPIConv 1.05 (english)
TMPGEnc 2.54

johnmeyer schrieb am 10.12.2010 um 00:03 Uhr
Not sure I can help much.

I found that in order to have VirtualDub and Avisynth scripts to be recognized by VFAPIconv, you have to copy ReadAVS.dll and ReadAVS.reg to the VFAPIconv dir.I have no idea what these two files are or where you got them from. I just did a complete search of all drives on my computer and didn't find them anywhere. I did find an ancient Zip file that contained these files, but the readme says that they are for TMPGEnc. So, I don't think you need these at all, and perhaps installing them has messed up something.

DebugMode Frameserver 2.7 is causing Vegas to crashI have only been using Frameserver with Vegas 8.0c and 7.0d. I haven't yet tried to install it for 10.0a. However, if you search these forum, going back a few months, you'll see a few recent threads about some changes you need to make to get it to work with 10.0a. I haven't done this myself yet, so I can't give you any direct advice, other than to read those posts.

I don't know if running proxyoff.reg, which comes with VirtualDub, as prescribed on Doom9 caused the problem or what.You don't need to run proxyoff.reg. Also, if you are trying to frameserve out of VirtualDub into Vegas, good luck. The whole point of using VFAPIConv is to AVOID frameserving out of VirtualDub. You should only use VirtualDub to check the operation of your script. After that, close down VirtualDub and use VFAPIConv to serve back into a second instance of Vegas. This avoids all manner of problems, including having to deal with the colorspace (YUY -> RGB) conversions in VirtualDub.

b) Now, Vegas won't render to "Video for Windows" if FrameServer was tried previously. I guess because it's still selected in the Render window before trying to change to video for windows format. Vegas 64 bit renders no problems using any option. After test rendering with Vegas 64 and going back to Vegas 32, the renders with FrameServer and Video for Windows (AVI) work okay for a while. Really strange things happening here in render land!I don't understand what you are trying to say.

Personally, I would NOT recommend trying to do any of this using the 64-bit version of Vegas. I have still yet to understand what the advantage of the 64-bit version is, except that in a few cases it does render a little faster. Other than that, my experience is that using it is a PIA, mostly because of the limitations in using third-party plugins and interfacing to the rest of the world. There needs to be a BIG incentive to make the jump (like 2x or better performance improvements) before it is worth all the hassle.

Just my opinion, you understand, but it is based on a little bit of actual hands-on.

2) The output produce by VFAPI Reader isn't readable by any of the programs on my PC i.e. Windows Media Player, Vegas10a, VirtualDUB1.9, TMPGEnc 2.5, etcNot sure why that is. The usual test to see if VFAPIConv is working is to open the AVI in exactly those programs.

So, in summary, I suspect that most of your problems are caused by using 64-bit stuff. Pretty much everything we're talking about here: AVISynth, VirtualDub, VFAPIConv, and even Vegas are much happier in 32-bit land. Do everything there, and forget about 64-bit, at least for doing this project.


goodrichm schrieb am 11.12.2010 um 14:57 Uhr
Looks like my post confused things a bit ;) I've been trying to follow your tut verbatim with the same programs, except I'm using Vegas pro 10a (32bit).

My first issue was that VFAPIConv wasn't letting me see nor open up the .avs script you posted in this thread. It would only load TMPGEnc .tpr project files.

So I went searching the net for the fix. I found the thread on DOOM9 where it talks about installing VFAPIConv and it said before you start converting you need to run proxyoff.reg in VirtualDub's folder. (See link in my above post.) That didn't work so I found the info on ReadAVS.dll and ReadAVS.reg in the links I posted above.

After copying them to VFAPIConv's folder, updating paths in ReadAVS.reg and running it, VFAPIConv now has new file type options to load aviSynth scripts and VirtualDub scripts.

VFAPIConv's converted output isn't opening up in Vegas 32bit so I tried other programs to see if it's Vegas related or not. I'm trying to follow your tut using the same programs as you except I have Vegas 10a (32bit).

I noticed in your tut that your VFAPIConv program looks different than the one I downloaded from DOOM9. They both are version 1.05 english, but apart from the ability to load avi scripts, your ver has buttons that say "Open File" and mine says "Load Job" instead. Do you remember where you downloaded yours from?

DebugMode's frameServer ver2.7 was working flawlessly in Vegas 10a (32bit) before installing VFAPIConv and running proxyoff.reg.

I'm sorry I confused things by mentioning Vegas 64 bit version, but I'm not using it at all with your slo-mo workflow. I'm not using VirtualDub either except to test aviSynth scripts as you. When I had problems with Vegas (32bit) rendering to any avi type, I tested normal avi renders in Vegas 64 bit to make sure I didn't hose something up with avi codecs or something. As you say, I don't use Vegas 64bit either because of plugin and codec compatibility issues.

Thank you for taking the time to respond and trying to help...MG
johnmeyer schrieb am 11.12.2010 um 15:46 Uhr
I'm sorry you were not able to get this to work. I think it would probably be best for you to just use Twixtor, Motionperfect, Slow Motion Smoother, Algolith, Magic Bullet or any of the other motion estimation commercial products.

goodrichm schrieb am 12.12.2010 um 17:10 Uhr
Can you point me to the place you got your copy of VFAPIConv?

Can you recommend a YUY2 codec?

Thanks again for all your help...MG
johnmeyer schrieb am 12.12.2010 um 22:43 Uhr
Can you point me to the place you got your copy of VFAPIConv?That link is provided in the YouTube tutorial itself (please read the comments I provided -- you will find them directly below the video screen on the YouTube page). However, if for some reason you can't find your way back to the tutorial, here is that link:

VFAPIConv (English Version) Download


Can you recommend a YUY2 codec?No, I can't, not because I don't have lots of codecs to recommend, but primarily because I don't understand the question.

I am puzzled by the question because I don't really understand why think you need a "YUY2 codec," whatever that is. Nothing in my tutorial or workflow requires any specific codec, and certainly doesn't require any codec between the video on the main Vegas timeline, and the resulting slow motion video that gets placed on the timeline in the second instance of Vegas. The whole idea of the workflow is to keep you from having to deal with colorspace issues that happen when you encode using codecs other than those included with Vegas. If you follow the workflow, then colors will not shift.


goodrichm schrieb am 13.12.2010 um 15:07 Uhr
Thanks so much for the link. It is a slightly different version than the one downloaded from Doom9; even though they're both english ver 1.05.

I'm talking about codecs because Vegas, VirtualDub, and every other program I've tried, is complaining that they can't read the VFAPIConv converted AVI file. The errors hint that Vegas, etc. can't find the correct codec to open the converted AVI file.

Please see error screen shots below.

Vegas error:
http://www.screencast.com/t/bkr3SDHr

VirtualDub error:
http://www.screencast.com/t/V5BFcIrM8TD

CODECs Installed:
http://www.screencast.com/t/nAMJeyg6


NickHope schrieb am 16.02.2011 um 14:08 Uhr
I also needed to do the readAVS trick that goodrichm describes in order to get VFAPIConv 1.05 to read .avs files. After I had done so, I can get it's fake .avi file to open in Vegas 10.0c.

I am on XP SP3 32-bit.

Note that VFAPIConv seems to require RGB output from the AviSynth script. It won't open YV12 for example.

Also note that my AviSynth test script is 1 line only and nothing to do with John's slomo process (yet).
craftech schrieb am 16.02.2011 um 15:08 Uhr
John,

I must have missed this when you posted it back in December.

Thank you for doing it. I lost count of the number of times you have gone out of your way to help people on this forum.

Regards,

John
johnmeyer schrieb am 16.02.2011 um 17:53 Uhr
Thank you for doing it. I lost count of the number of times you have gone out of your way to help people on this forum.Thanks for those kind words, John. Sometimes my posts get a little long, and some of my stuff is rather geeky, but hopefully sometimes it is useful.
NickHope schrieb am 04.03.2011 um 10:04 Uhr
I've recently reinstalled XP SP3 on the same machine and I now find that I don't need the readAVS script any more. VFAPIConv 1.05 is working fine without it. I'm using this version and I installed by running the vifpset.bat file from the zip download. Also it's working with YV12 now as well. I have no idea what the problem was before.