Thursday, June 15, 2017

Tutorial #2 - Converting DVDs to editable video files

After my last tutorial, I decided to focus on improving my antiquated DVD-ProRes workflow.

Thankfully, newer software can make this process a lot simpler.

A program called MakeMKV works as a sort of all-in-one DVD/Blu-Ray extracting program, and unlike most similar programs, the resulting file is not only all in a single file, but is not recompressed. You get an .mkv wrapper around the video and audio that you choose to extract, and that's about it.

From there, you can use the FFmpegSource filter in AVISynth to load the file, and then apply any additional processing you need. If MakeMKV detects your footage as being 24p, then it will include that metadata in its .mkv, so you shouldn't have to go through the IVTC process. If it detects it as 60i, then you can use QTGMC and it should work... however, the preview window in AVSPmod can be a little glitchy when using FFmpegSource, and scrubbing back and forth may introduce hitches not present in the rendered end result.

One additional note: FFmpegSource needs to index the file before loading it, so don't worry if it takes a long time to load initially. This index is dumped into an .ffindex file in the same folder as your video file, which will load automatically in the future.

I should mention, however, that this process doesn't work on all DVDs. Some will have audio sync issues, and need an alternate (and more complicated) workflow with its own benefits and tradeoffs that I'll outline in a future post.

I will try to get a video tutorial out in the near future, but I keep coming up with edge case issues that need to be addressed, so it might be a while. When it's ready, I'll update this post.


BIG 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 benign programs.

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 where you go to get the software:

MakeMKV

AVISynth (You will need both the 32-bit "Official" build and the 32-bit "Unofficial" multi-threaded build)

FFmpegSource

If you're going to be dealing with 60i footage, then you'll probably want to deinterlace with QTGMC. If you need to know how to do this, check out my previous blog post.

QTGMC (Get the QTGMC download, then get both the "required" and "optional" filters as listed on the page. If there's a choice, get the 32-bit [x86] version of filters.)

LimitedSharpen (Technically LimitedSharpenFaster. Optional. Get the x86 version in order for it to work within a script using QTGMC. )

FFMPEG Windows Binaries (Get the current 32-bit static version)

AvsPmod

Setup:

  1. Install MakeMKV.
  2. Run the main AVISynth installer. 
  3. Put the AVISynth filters you downloaded (.dlls and .avsi files) in the AVISynth Plugins directory. Make sure to use the 32-bit (x86) versions of any filters if there is a choice. Make sure you're using version 2.2.7 (or later) of MaskTools2.
  4. Copy the multithreaded build of avisynth.dll to your system folder (Usually C:/Windows/SysWow64/) and replace the existing file.
  5. Copy the libfftw3f-3.dll file your system folder.
  6. Extract FFMPEG and AvsPmod to their own folders. Keep the folder with the ffmpeg.exe binary open.
  7. Set up FFMPEG to run from any directory on your PC by adding it to your PATH variable:
    1. Press the Windows and R keys.
    2. Type "control sysdm.cpl,,3". Click "Run".
    3. Click on "Environment Variables".
    4. Select "Path" under "System variables" and click "Edit".
    5. 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.
    6. 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.

Process:

Open MakeMKV.

Put a DVD in your optical drive. Open the DVD in MakeMKV.

Select the Titles and Audio tracks that you want to copy over. Select the output directory. Click on the Save to MKV button.

When done, close MakeMKV and go to the directory you just saved the .mkv file to.

In the same directory as your .mkv file, make an .avs script with the settings listed below. Change the filename, source filter, and crop settings as necessary.

Here's my boilerplate .avs script settings:

SetMTMode (5, 10)
FFmpegSource2("videofile.mkv", atrack=1)
ConvertToYV12()

If you're using 4:3 video, then a pixel aspect ratio conversion is necessary (unless you'll be outputting back to DVD...in which case, ugh):
BilinearResize(720,540)

And here's what to add if you want to upscale to 720p HD:
BilinearResize(1280,720)

You can also use Lanczos4Resize or Spline64Resize on the last resize step if you need some overall sharpening. I'll also sometimes use LimitedSharpenFaster at the end for a little extra punch.

LimitedSharpenFaster()
Please keep in mind that DVD video tends to have lots of compression artifacts, and sharpening can accentuate them.

Working on this script in AvsPmod will let you preview your results, and change them to your preference. When you're done, don't forget to save your work.

Create a new text file in the same directory and change its extension to .bat. Add the FFMPEG commands of your choice. For example, here's a command to encode an .avs script to a ProRes 422HQ Quicktime file:

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

Change where necessary. The quotes around the filenames in the FFMPEG command allow you to enter path addresses and filenames with spaces in them.


No comments: