Lisa Melton provides some amazing scripts that wrap HandBrake to produce high quality, portable versions of Blu-ray rips. The tools Lisa provides are written in Ruby, and they're packaged as a Ruby Gem. All the tools are cross platform, requiring only the Ruby runtime to be installed. But they do depend on external programs to get anything useful done. These dependencies are cross platform as well, but Windows has no standard package management system (de facto or otherwise), so installing these dependencies for Windows can be a bit of a pain. But it is possible! There are several ways to go about installing these tools and their dependencies, the two discussed here are to use Bash on Ubuntu on Windows (which is what we recommend for users of Windows 10), but if you have an older version of Windows you can also download Windows versions of everything that's needed.
If you're using an up-to-date version of Windows 10, you have access to "Bash on Ubuntu on Windows". This feature allows you to run command line Linux programs on Windows without using a virtual machine, and it also gives you access to Ubuntu's extensive package archives. Everything you need to run these scripts is easily installable with apt-get.
- First up, you need to activate Bash.
- Follow Microsoft's instructions to enable the Windows Subsystem for Linux, then install Ubuntu 18.04 from the Microsoft Store
- Next you install the dependencies for
video_transcoding
. Inside of bash:- Run
sudo apt-get update && sudo apt-get upgrade
to ensure everything's up to date - Run
sudo apt-get install ruby ffmpeg mp4v2-utils mkvtoolnix
- Install HandBrakeCLI
sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo apt-get update
sudo apt-get install handbrake-cli
- Run
- Now you can install
video_transcoding
sudo gem install video_transcoding
The detect-crop
command has an optional dependency on mpv
for previewing crops. You can't launch graphical Linux apps using "Bash on Ubuntu on Windows", but it is capable of launching Windows programs; this means you can install mpv
for Windows, then use an alias to launch it from bash:
- Create
C:\bin
and add it to your path - Download a Windows build of mpv from here
- Extract it to
C:\bin
- Create an alias for mpv:
echo "alias mpv=mpv.exe" >> .bashrc
- Reload
.bashrc
by runningsource ~/.bashrc
If you have your movie files in the Windows file system (so NOT in ~userfolder/AppData/Local/lxss/home
), for example on your desktop, you have to provide the path to it via /mnt/[drive letter]/path/to/your/file/location
. You can also navigate to the folder in Explorer, then type bash in the address bar to open a bash instance to that location
In old versions of Windows 10, or in Windows 8.1 and earlier, you either don't have access to Bash on Ubuntu on Windows or the version that's there can't be used to do this. All the dependencies are available for Windows though, you just need to track them down:
- HandBrakeCLI
Get the latest stable version - ffmpeg, the download page for Windows is here
Get the latest stable 'static' release. - mkvtoolnix, the download page for Windows is here
Download the latest portable version. It's packaged as a .7z file, I'd recommend using 7zip to open these files - mpv, the download page for Windows is here
Get the latest version - MP4v2
Functional Windows binaries for this are hard to find, I've been using this one. If anyone knows of a more official binary, please file an issue or tweet at me - RubyInstaller
- Download everything from the links above
- Run the Ruby installer and make sure "Add to path" is ticked during install. Don't run the
ridk install
step at the end, you don't need this forvideo_transcoding
- Create
C:\bin
and add it to your PATH - From the HandBrake zip file extract
HandBrakeCLI.exe
toC:\bin
- From the ffmpeg zip file extract
bin\ffmpeg.exe
toC:\bin
- From the MKVToolNix 7z file extract
mkvpropedit
and thedata\
directory toC:\bin
- From the MP4v2 7z file extract
libmp4v2.dll
andmp4track.exe
toC:\bin
- From the mpv 7z file extract
mpv.exe
toC:\bin
C:\bin
should now contain:- data\
- ffmpeg.exe
- HandBrakeCLI.exe
- libmp4v2.dll
- mkvpropedit.exe
- mp4track.exe
- mpv.exe
- Open
cmd.exe
and rungem install video_transcoding
- Right click
Start
- Open Control Panel
- Search for "Path"
- Click "Edit System Environment Variables"
- Click the "Environment Variables" button in the lower right corner
- In the System Variables box find "PATH" and select it
- Click the "Edit" button
Batch control can be achieved with the following .bat file:
@echo off
setlocal EnableDelayedExpansion
set work=%cd%
set queue=%work%\queue.txt
set crops=%work%\Crops
for /F "tokens=*" %%I in (queue.txt) do (
set title_name=%%~nI
set crop_file=%crops%\!title_name!.txt
if exist !crop_file! (
for /F "tokens=* USEBACKQ" %%F in (`type "!crop_file!"`) do set crop_option=--crop %%F
) else (
set crop_option=
)
call transcode-video !crop_option! "%%I"
)
It works in much the same way that Lisa's bash script works, although it does have the limitation of not being able to "resume" the queue in the way that Lisa's does. I would recommend creating a batch-transcode.bat
file in your C:\bin
folder, then you can create the necesarry file structure anywhere:
Crops\
queue.txt
In CMD you can CD
to that directory, populate the queue.txt
file then simply call batch-transcode
and it'll transcode everything in the queue
To create a queue.txt
with every mkv file in a directory you can use the following command:
for %a in (*.mkv) do echo %~fa >> queue.txt