Poll: How much do you want to try AviSynth+?
This poll is closed.
Hook it right into my venes!
100.00%
1 100.00%
Nah nah nah, leave me alooooooone!
0%
0 0%
Total 1 vote(s) 100%
* You voted for this item. [Show Results]

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Guide: Upgrade to AviSynth+ for high bit depth support
#1
Now that the age of HDR is here and also with x264 supporting 10 bit encoding, I've been annoyed by AviSynth's lack of support for bit depths above 8 bit per channel.

I've known for a while that AviSynth+ natively supports higher bit depths, but been always concerned that it may break compatibility with older plugins and scripts, which would be pretty stupid.

Luckily, I read today that AviSynth+ is actually very compatible with old plugins and upgrading to it is actually fairly easy.

This shall be a short guide on how to upgrade to AviSynth+ while keeping your old scripts functional and making use of higher bit depths, based on my initial experiences.

1. Get the newest release of AviSynth+. There are some older releases floating around, which led to me initially being unable to use the higher bit depth feature. You can find the newest release here: https://github.com/pinterf/AviSynthPlus/releases

2. According to the documentation, you can leave your old AviSynth installed and install AviSynth+ over it. During installation, you are given the (default) option to simply make use of the old plugin paths for the older compatible plugins. Upon deinstallation of AviSynth+, the old paths etc. would be restored and you would be safely switched back to your old AviSynth. I personally felt that this was cumbersome and deinstalled AviSynth first opting for "do not delete plugin paths"; this did not delete my plugin folders. Then I installed AviSynth+ which gave me the same option I mentioned from the documentation - to keep the old plugin folders in the path and automatically load any needed plugins from there.

3. After the installation, pretty much everything *should be* as you're used to it.


4. Get VirtualDub FilterMod and use this instead of normal VirtualDub for previewing your work. This is because normal VirtualDub does not support deep color/high bit depths and will throw an error if you attempt to use higher bit depths.

5. Note that AviSynth+ (as well as VirtualDub Filtermod) comes in both 32 bit and 64 bit version in the same package. Which version gets actually used depends *solely* on whether the app you use AviSynth with (avisynth being a library) is 32 bit or 64 bit. This means that if you open your avs file in VirtualDub Filtermod 64 bit (it's a seperate file called veedub64.exe), then you are using the 64 bit version of AviSynth+ which does NOT have access to the 32 bit plugins of the old AviSynth that you need. Hence, use the normal 32 bit VirtualDub Filtermod and you're good! Same goes for ffmpeg versions btw. - a 64 bit ffmpeg will call the 64 bit AviSynth+ library.

6. Test one of your scripts. If you, like me, get a popup called "System Exception - Access Violation", then you have some incompatible plugins in your plugins folder. I had this error and made post about it over on Doom 9 (Permalink). AviSynth+ uses an AutoLoader for plugins. This means that when you call an unknown function, the plugin directories are scanned for plugins. If there is any plugin in your plugin folder that is not fully compatible, it will throw this error (even if the plugin you are trying to use *is* compatible). There are two solutions to this. First solution: Move all your plugins into a temporary folder, then move them back in batches while testing the script again - that way you can find out which plugin (likely some unimportant niche plugin you never used anyway) is making trouble. Second solution: Add ClearAutoloadDirs() to the beginning of the script. This will completely disable AutoLoading. Then simply manually load every plugin you need like this: Loadplugin("C:\Program Files (x86)\AviSynth\plugins\ffms2.dll")

7. To use higher bit depths, use the ConvertBits function. It's as simple as srcclip = srcclip.ConvertBits(16) for 16 bit depth per channel. This should not create any visible change in your preview, as your display (likely) and VirtualDub (likely) only supports 8 bit preview anyway. But it will improve postprocessing as long as the filters support it. For example, if you do some kind of averaging of various sources or color/levels manipulation, you will have 255x the former precision per channel and 16,777,216x more available colors in the spectrum overall. I think you can go even deeper than 16 bits per channel.

8. The resulting script can be encoded as you are used to it. If you want to use a 64 bit software for encoding, like x264 64bit builds, then you can use a neat little software called avs2pipemod to pipe your 32-bit AviSynth script into a 64 bit tool. For example, here's an overly convoluted commandline I am using to pipe a 16 bit depth 32bit AviSynth+ script into 64 bit ffmpeg, where I apply a 3D LUT and further pipe it into x264 64 bit for final encoding:
Code:
avs2pipemod -rawvideo grain-16bitversion.avs|ffmpeg -f rawvideo -pix_fmt bgra64le  -s 1920x800 -r 24000/1001 -i pipe:0 -c:v prores -vf lut3d="collectall-sorted-REFERENCE_50p_50p_8bit.secondtry.mat.cube.darkenedinPS-nobluehue.CUBE" -pix_fmt yuv444p16le -vcodec rawvideo -f rawvideo - 2>null2 | x264_x64_10bit_tmod.exe --preset=veryslow --tune=grain --b-adapt=2 --deblock=-3:-3 --rc-lookahead=60 --keyint=400 --min-keyint=40 --me=umh --merange=64 --psy-rd=1.0:0.10 --aq-mode=3 --qpstep=40 --partitions=all --no-dct-decimate --bframes=16 --no-dct-decimate --no-fast-pskip --deadzone-inter 0 --deadzone-intra 0 --aq-strength=4 --aq3-mode=1 --aq3-strength=4 --aq3-boundary=820:224:36 --trellis=2 --qcomp=1 --subme=11 --ref=8 --crf 30 --output="Armarendron.264" --profile high444  --input-csp i444 --output-csp i444 --input-res 1920x800 --input-depth=16 --frames=216988 --fps=24000/1001  -

(Yes, it does actually work!)

Conclusion

Upgrading is really a breeze and of course totally worth it. The only problem you *may* encounter are some incompatible plugins in your plugin folder resulting in nasty error messages. But, Uncle Tom already told you what to do about that (step 6), so no need for worrying. How compatible is it? Well, I haven't tested THAT much yet, but let me just say ... there's this rather obscure AviSynth plugin called FQSharpen, written by some random dude with terrible horrible documentation that likely wasn't touched for 10 years ... and it works! FFmpegSource2 also works!

Oh, regarding that avs2pipemod I recommended ... for some reason it flips the image for me ... dunno why. FlipVertical() at the end of my script put that error out of its misery!
Reply
Thanks given by: spoRv
#2
Thanks! Sooner or later I'll find the courage to switch to it... Happy
Fundamental collection thread | Vimeo channel | My personal blog
Reply
Thanks given by: TomArrow
#3
Think about what you can do ... regrade 10 Bit UHD sources with your ColorMatch™ technique without introducing banding! Wink
Reply
Thanks given by:


Possibly Related Threads...
Thread Author Replies Views Last Post
  Beginners Guide To Syncing Audio alexpeden2000 16 3,451 2018-07-15, 07:52 AM
Last Post: maksnew
  Dummies guide to AviSynth? Jetrell Fo 11 3,667 2016-08-01, 09:11 AM
Last Post: jerryshadoe

Forum Jump:


Users browsing this thread: 1 Guest(s)