Wednesday, October 31, 2018

Tutorial - Installing 64-bit and 32-bit AVISynth+, QTGMC, and FFMPEG side by side

Hey folks - just wanted to let you know that this tutorial is now officially outdated.  I'm leaving it up here are for up historical interest, but here's a link to a post that I will maintain from this point forward with the current instructions for setting up AVISynth and QTGMC:



============================================



So, it turns out I made a mistake. I assumed that QTGMC still didn't work properly in 64-bit AVISynth, even though it had been over a year since I looked into it.

Not only does it work, it actually gives a 10%-20% speed boost during rendering.

However, there is one particular hitch that holds it back a bit: AvsPMod 64-bit throws up error messages when you use the video preview function. It's not a deal-breaker, but it's annoying. Hopefully, a newer version will come out soon. In the meantime, in the interest of both correcting my error and of finally putting the setup tutorial videos to rest, I'm going to show how to install and run the 32 and 64-bit versions of AVISynth+, QTGMC and FFMPEG side by side.


BIG DISCLAIMER: This process may not work, may crash, or do other things to your system. Always check your files before submitting/uploading them.

Virus scan everything you download. It's not a 100% guarantee that you'll avoid getting a malware infection, but it's a lot better than not checking at all.

You have been warned. 

Also, this tutorial is for Windows 10. Most of the steps work for previous versions of Windows, but may require slight modifications. Users of MacOS and other OSes should look elsewhere.


Here's the video version of the tutorial:



Also, I will be rushing through some of the initial steps for 32-bit AVISynth+, so if you'd like a little more depth, check out my original tutorial first, or check out my video version of that tutorial:





BIG DISCLAIMER: This process may not work, may crash, or do other things to your system. Virus scanning all files is strongly encouraged, but not a 100% guarantee of safety.

You have been warned. 

If you're on a deadline (and using Premiere Pro, After Effects, or Final Cut Pro) probably your best best is to use a paid plugin like FieldsKit. And no, they aren't paying me to say that.

Also, this tutorial is for Windows 10. Most of the steps work for previous versions of Windows, but may require slight modifications. Users of MacOS and other OSes should look elsewhere.





First of all, AVISynth+ installs both the 32-bit and 64-bit versions by default. You can grab it from here:

https://github.com/pinterf/AviSynthPlus/releases

Then, we'll need to get all the filters (plugins) needed:

FFMPEGSource

11/6/2018 Update: looks like Jiangmin antivirus is currently flagging FFMpegSource with a warning on VirusTotal. Given that no other antivirus engines have spotted anything, I'm cautiously calling this a false positive, especially because one of the top search results for Jiangmin on Google is a post about the problems with reporting false positives to them.

QTGMC

Don't forget to get all the "Core Plugins", along with 32-bit FFTW3 library as well.


If you need to sharpen the image, I recommend LimitedSharpen (Technically "LimitedSharpenFaster")

With all the AVISynth filters and scripts grabbed, it's time to get the supporting software:

AvsPMod

This is like an IDE for AVISynth scripts, and is pretty much essential IMO. Be sure to grab both the 32-bit and 64-bit versions.

FFMPEG

Update: since Zeranoe has shut down, I will be recommending compiling 32-bit FFMPEG from source using https://github.com/m-ab-s/media-autobuild_suite . Since this tutorial is getting a little long in the tooth any ways, I'll just leave this here as a placeholder until I create a newer and better version. You can get the 64-bit version here: https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-essentials.zip 

7-zip

If you don't have 7-zip already installed, you won't be able to open many of the downloaded archives. The version you get here doesn't matter, so maybe just do the 64-bit one.

After virus scanning everything, install:

7-zip (if needed)
AVISynth+

Just follow the default options in both cases. Then, go to the 32-bit plugins directory for AVISynth+. On my system, this is:

C:\Program Files(x86)\AVISynth+\plugins+\

Extract all .dll and .avsi files to the plugins directory from all plugins EXCEPT the fftw-3*.dll archive. If there's a choice between an x86 and an x64 version, use the x86 version. If there's a choice between AVX, AVX2 and a version without either, you'll need to know what instruction sets your processor supports. CPU-Z can tell you this if you're not sure.

Once that's done, do the same with the 64-bit versions of the plugins, except copy those to the "plugins64+" folder.

Now, open the fftw-3*.dll archive, then (as noted on the QTGMC page) extract the libfftw3f-3.dll file. Make a copy of it and rename it as "FFTW3.dll". Place the files "libfftw3f-3.dll" and "FFTW3.dll" in the SysWow64 folder.

Extract the 32-bit AvsPMod archive to wherever you want to run it from, and then extract the 64-bit version to a different directory. If you want to associate .avs files with AvsPMod, I would generally recommend doing so with the 32-bit version, but if you work primarily in 64-bit, then you should probably use that version.

Now, for the tricky part: setting up both the 32 and 64-bit versions of FFMPEG to run from any directory on your computer. We're going to do this with batch files. Also, kudos to Jon Hall's tutorial blog post on FFMPEG setup (currently defunct) for showing me basically how to do this.

First, open the 32-bit FFMPEG archive, then open the long-named folder within.

Create a folder somewhere on your system called "ffmpeg32". Personally, I put it in Program Files (x86).

Copy the "bin" and other folders from the opened FFMPEG archive to your ffmpeg32 folder.

Create a new text file, then rename it to "ffmpeg32.bat".

Right-click on the batch file and select "edit".

Write some version of the following into the notepad window:

@ECHO OFF
"C:\Program Files (x86)\ffmpeg32\bin\ffmpeg.exe" %*
Adjust the path as needed depending on where you installed 32-bit FFMPEG. Save, close batch file. Keep the explorer window showing the contents of your ffmpeg32 folder open.

Do the above steps for the 64-bit version of FFMPEG, except change the folder name to "ffmpeg64" and the batch file name to "ffmpeg64.bat". In the batch file, put some version of the following:

@ECHO OFF
"C:\Program Files\ffmpeg64\bin\ffmpeg.exe" %*
As you can see, I put ffmpeg64 in Program Files, but again, you can put it wherever you want.

Save, and close the batch file. Keep the explorer window showing the contents of your ffmpeg64 folder open.

Now, to add both versions of FFMPEG to your system path:
  1. Press the Windows and R keys.
  2. Type "control sysdm.cpl,,3". 
  3. Click "Run".
  4. Click on "Environment Variables".
  5. Select "Path" under "System variables" and click "Edit".
  6. Go to where your ffmpeg32.bat file is. 
  7. Select and copy the folder's path address from the address bar towards the top of the window.
  8. Back in the "Edit environment variable" window, click "New" and paste in the folder path. 
  9.  Repeat steps 6-8, but use the location of your ffmpeg64.bat file.
  10. Click OK on all the windows you opened to get here.
To make sure everything worked, open a command prompt (or Powershell, whatever your preference), then type ffmpeg32. If a long list of options is shown after a moment, cool. Do the same with ffmpeg64. If neither shows an error message like "command not found", you should be good to go.

Now, whenever you make your .bat file to run ffmpeg, you can specify whether you want to run the 32-bit version of both FFMPEG and AVISynth by calling ffmpeg32, like so:

    ffmpeg32 -i "videofile.avs" -c:v prores -profile:v 3 -pix_fmt yuv422p10le "output.mov"

If you want to run the 64-bit versions of FFMPEG and AVISynth, just call ffmpeg64 instead, like so:

    ffmpeg64 -i "videofile.avs" -c:v prores -profile:v 3 -pix_fmt yuv422p10le "output.mov"

PS: FFMPEG doesn't generate "official" ProRes files, so if it will be the last stop in your export chain, consider using a different workflow if the file is going to a major TV channel. Some channels have reportedly (on Reddit's /r/editors subreddit) said that FFMPEG ProRes files won't pass QC with them.

Wednesday, October 17, 2018

Tutorial - Alternate Setup for FFMPEG, Alternate Install for AVISynth+

Hey folks - just wanted to let you know that this tutorial is now officially outdated.  I'm leaving it up here are for up historical interest, but here's a link to a post that I will maintain from this point forward with the current instructions for setting up AVISynth and QTGMC:



============================================



There are a few setup options that I didn't cover in my last tutorial that I do on my own system to make my life easier when dealing with AVISynth and FFMPEG.

I like to set up FFMPEG to run on any folder on my system, as opposed to having to drop the ffmpeg.exe binary in the folder every time. I also like using the Univsersal AVISynth installer, which allows me to easily install/uninstall different versions of AVISynth, and is just generally cleaner than the official AVISynth+ installer.

DISCLAIMER: 

This process may not work, may crash, or do other things to your system. I check for viruses before using any software, but malicious hackers have been known to break into developer accounts and insert code into previously benign programs, and even regular programs can have bugs.

This is a post accompanying a YouTube tutorial. Video is here:



First, let's set up FFMPEG. I basically already covered this in my now-archived original method for setting up QTGMC, but here's a recap: 
  1. Download and virusscan the latest nightly 32-bit static build of FFMPEG. 

    Update: since Zeranoe has shut down, I will be recommending compiling 32-bit FFMPEG from source using https://github.com/m-ab-s/media-autobuild_suite . Since this tutorial is getting a little long in the tooth any ways, I'll just leave this here as a placeholder until I create a newer and better version. 

  2. Open the downloaded FFMPEG archive. Open the long-named folder within. 
  3. Create a new FFMPEG folder somewhere on your main drive. 
  4. Copy all the files in the opened archive folder to your new FFMPEG folder. 
  5. Press the Windows and R keys or go to the start menu and type "run" and click on the run option. 
  6. Type "control sysdm.cpl,,3". Click "Run". 
  7. Click on "Environment Variables". 
  8. Select "Path" under "System variables" and click "Edit". 
  9. Go back to your open folder where ffmpeg.exe is located. Select and copy the folder's path address from the address bar towards the top of the window. 
  10. Back in the "Edit environment variable" window, click "New" and paste in the folder path. Click OK on all the windows you opened to get here. 
When that's done, you can now run FFMPEG from any directory on your computer, and your .bat files that call FFMPEG will do the same.


Now, for the Universal AVISynth Installer (which I will refer to as the UAI for the rest of this post).

  1. Grab the UAI archive file from here. Virus scan it. 
  2. Open the file. You'll notice there's a folder inside called "AVISynthRepository". 
  3. Open another window with the location where you want the UAI to go. Copy the AVISynthRepository folder over to that location. 
  4. Close the archive window. Open up the folder from where you just copied it to. 
  5. Right-click on the setavs.bat and select "Edit". This will open the .bat file in Notepad. 
  6. Look for the line that says ":set AVS_SRC_DIR=%~dp0". Remove the colon so it now reads: "set AVS_SRC_DIR=%~dp0". Save and close Notepad. 
  7. Right-click on the .bat file and select "Run as administrator". Say yes to the UAC prompt. 
  8. Type 6, hit enter. 
  9. Open up the AVSPLUS_x86 folder, then the plugins folder. 
  10. Copy over all your desired AVISynth plugins (aka filters). 
  11. Set up any additional system .dll files as necessary.
To uninstall:
  1. Right-click on the .bat file and select "Run as administrator".
  2. Say yes to the UAC prompt. 
  3. Type 8 to uninstall any 32-bit versions of AVISynth.
  4. Type 9 to uninstall any 64-bit version. 
  5. Hit enter. Type y, hit enter. 

Please note that you can install 64-bit AVISynth+ either instead of or alongside the 32-bit version. Its filters would then go in the plugins folder inside the AVSPLUS_x64 folder. To preview a script with 64-bit filters, you'll need the 64-bit version of AVSPmod. To render using 64-bit AVISynth, you'll need to use the 64-bit version of FFMPEG. You can follow the above setup instructions for FFMPEG I've described above, or go to this post to see how to set up both the 32 and 64-bit versions at the same time and use either at will.



Bonus unnecessary info:

If you need to do step 11 of the setup process a lot, you can copy the files over to the directory of whatever version of AVISynth you're running (in the case of the above tutorial, AVSPLUS_x86), then add entries to the .bat file to have them copied over and uninstalled as part of the script. To do so, edit the .bat file.

For example, if I wanted to add the FFTW3 library files to the install, I would change:

) else (
echo copying %avs% files to "%WINDIR%\SysWow64"...
echo copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\SysWow64"
copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\SysWow64"
copy /y "%AVS_SRC_DIR%\%avs%\devil.dll" "%WINDIR%\SysWow64"

so it becomes:


) else (
echo copying %avs% files to "%WINDIR%\SysWow64"...
echo copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\SysWow64"
copy /y "%AVS_SRC_DIR%\%avs%\avisynth.dll" "%WINDIR%\SysWow64"
copy /y "%AVS_SRC_DIR%\%avs%\devil.dll" "%WINDIR%\SysWow64"
copy /y "%AVS_SRC_DIR%\%avs%\FFTW3.dll" "%WINDIR%\SysWow64"
copy /y "%AVS_SRC_DIR%\%avs%\libfftw3f-3.dll" "%WINDIR%\SysWow64"

To allow the installer to uninstall those files, I would change:

) else (
echo removing %avs% files from "%WINDIR%\SysWow64"...
del "%WINDIR%\SysWow64\avisynth.dll"
del "%WINDIR%\SysWow64\devil.dll"

so it becomes:

) else (
echo removing %avs% files from "%WINDIR%\SysWow64"...
del "%WINDIR%\SysWow64\avisynth.dll"
del "%WINDIR%\SysWow64\devil.dll"
del "%WINDIR%\SysWow64\libfftw3f-3.dll"
del "%WINDIR%\SysWow64\FFTW3.dll"

Which deinterlacing algorithm is the best? Part 1 - HD interlaced footage

Before I began, I'd like to give a special thanks to Aleksander Kozak for his help in testing and providing the HD footage used in this ...