└── README.md /README.md: -------------------------------------------------------------------------------- 1 | ## Transcoding video on Windows, the Lisa Melton way 2 | 3 | Lisa Melton provides some [amazing scripts](https://github.com/lisamelton/video_transcoding) that wrap [HandBrake](https://handbrake.fr/) to produce high quality, portable versions of Blu-ray rips. The tools Lisa provides are written in [Ruby](https://www.ruby-lang.org/en/), and they're packaged as a [Ruby Gem](https://rubygems.org/). 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](https://msdn.microsoft.com/en-gb/commandline/wsl/about) (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. 4 | 5 | ### Windows 10 6 | If you're using an up-to-date version of Windows 10, you have access to "[Bash on Ubuntu on Windows](https://msdn.microsoft.com/en-gb/commandline/wsl/about)". 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. 7 | 8 | 1. First up, you need to activate Bash. 9 | 1. Follow [Microsoft's instructions](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to enable the Windows Subsystem for Linux, then install Ubuntu 18.04 from the Microsoft Store 10 | 1. Next you install the dependencies for `video_transcoding`. Inside of bash: 11 | 1. Run `sudo apt-get update && sudo apt-get upgrade` to ensure everything's up to date 12 | 1. Run `sudo apt-get install ruby ffmpeg mp4v2-utils mkvtoolnix` 13 | 1. Install HandBrakeCLI 14 | 1. `sudo add-apt-repository ppa:stebbins/handbrake-releases` 15 | 1. `sudo apt-get update` 16 | 1. `sudo apt-get install handbrake-cli` 17 | 1. Now you can install `video_transcoding` 18 | 1. `sudo gem install video_transcoding` 19 | 20 | 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: 21 | 22 | 1. Create `C:\bin` and [add it to your path](#adding-a-folder-to-your-path) 23 | 1. Download a Windows build of [mpv](https://mpv.io/) from [here](https://mpv.srsfckn.biz/) 24 | 1. Extract it to `C:\bin` 25 | 1. Create an alias for mpv: 26 | `echo "alias mpv=mpv.exe" >> .bashrc` 27 | 1. Reload `.bashrc` by running `source ~/.bashrc` 28 | 29 | 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 30 | 31 | ### Pre Windows 10 Creators Update and earlier 32 | 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: 33 | 34 | - [HandBrakeCLI](https://handbrake.fr/downloads2.php) 35 | Get the latest stable version 36 | - [ffmpeg](https://ffmpeg.org/download.html), the download page for Windows is [here](http://ffmpeg.org/download.html#build-windows) 37 | Get the latest stable 'static' release. 38 | - [mkvtoolnix](https://mkvtoolnix.download/downloads.html#windows), the download page for Windows is [here](https://www.fosshub.com/MKVToolNix.html) 39 | Download the latest portable version. It's packaged as a .7z file, I'd recommend using [7zip](http://www.7-zip.org/download.html) to open these files 40 | - [mpv](https://mpv.io/), the download page for Windows is [here](https://mpv.srsfckn.biz/) 41 | Get the latest version 42 | - [MP4v2](https://code.google.com/archive/p/mp4v2/) 43 | Functional Windows binaries for this are hard to find, I've been using [this one](http://forum.doom9.org/showthread.php?t=171038). If anyone knows of a more official binary, please [file an issue](https://github.com/JMoVS/installing_video_transcoding_on_windows/issues/new) or [tweet at me](https://twitter.com/_samhutchins/) 44 | - [RubyInstaller](https://rubyinstaller.org/downloads/) 45 | 46 | 1. Download everything from the links above 47 | 1. 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 for `video_transcoding` 48 | 1. Create `C:\bin` and [add it to your PATH](#adding-a-folder-to-your-path) 49 | 1. From the HandBrake zip file extract `HandBrakeCLI.exe` to `C:\bin` 50 | 1. From the ffmpeg zip file extract `bin\ffmpeg.exe` to `C:\bin` 51 | 1. From the MKVToolNix 7z file extract `mkvpropedit` and the `data\` directory to `C:\bin` 52 | 1. From the MP4v2 7z file extract `libmp4v2.dll` and `mp4track.exe` to `C:\bin` 53 | 1. From the mpv 7z file extract `mpv.exe` to `C:\bin` 54 | `C:\bin` should now contain: 55 | - data\ 56 | - ffmpeg.exe 57 | - HandBrakeCLI.exe 58 | - libmp4v2.dll 59 | - mkvpropedit.exe 60 | - mp4track.exe 61 | - mpv.exe 62 | 1. Open `cmd.exe` and run `gem install video_transcoding` 63 | 64 | ### Adding a folder to your PATH 65 | 1. Right click `Start` 66 | 1. Open Control Panel 67 | 1. Search for "Path" 68 | 1. Click "Edit System Environment Variables" 69 | 1. Click the "Environment Variables" button in the lower right corner 70 | 1. In the System Variables box find "PATH" and select it 71 | 1. Click the "Edit" button 72 | 73 | ## Further information 74 | ### Batch control in `cmd.exe` 75 | Batch control can be achieved with the following .bat file: 76 | ``` 77 | @echo off 78 | 79 | setlocal EnableDelayedExpansion 80 | 81 | set work=%cd% 82 | set queue=%work%\queue.txt 83 | set crops=%work%\Crops 84 | 85 | for /F "tokens=*" %%I in (queue.txt) do ( 86 | set title_name=%%~nI 87 | set crop_file=%crops%\!title_name!.txt 88 | 89 | if exist !crop_file! ( 90 | for /F "tokens=* USEBACKQ" %%F in (`type "!crop_file!"`) do set crop_option=--crop %%F 91 | ) else ( 92 | set crop_option= 93 | ) 94 | 95 | call transcode-video !crop_option! "%%I" 96 | ) 97 | ``` 98 | 99 | It works in much the same way that Lisa's [bash script](https://github.com/lisamelton/video_transcoding#batch-control-for-transcode-video) 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: 100 | ``` 101 | Crops\ 102 | queue.txt 103 | ``` 104 | 105 | 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 106 | 107 | To create a `queue.txt` with every mkv file in a directory you can use the following command: 108 | `for %a in (*.mkv) do echo %~fa >> queue.txt` 109 | --------------------------------------------------------------------------------