Skip to content

Instantly share code, notes, and snippets.

@JMoVS
Last active January 18, 2017 17:42
Show Gist options
  • Save JMoVS/75f3c6b344648deef59bc761e5e5a0e6 to your computer and use it in GitHub Desktop.
Save JMoVS/75f3c6b344648deef59bc761e5e5a0e6 to your computer and use it in GitHub Desktop.
How to get Don Meltons excellent video_transcoding scripts to work in win10's subsystem for linux

How to get to a working setup of the video_transcoding scripts on windows 10's subsystem for linux

With the upcoming (aka Spring win 10 update), this process will get a lot easier as some things like patchelf and other things are getting fixed, obleviating the need for some workarounds still present in this gist

How to update when you successfully installed all this

sudo apt-get update && sudo apt-get upgrade
brew update && brew upgrade
sudo gem update video_transcoding

Rationale

I wanted a way I could provide my father on his windows 10 machine to sort of easily transcode the videos and I was never able to work with Cygwin (and also didn't research deeply into it). Coincidentally, Microsoft announced and shipped the linux subsystem for windows, so I thought, let's use this.

What needs to be done

We essentially want just the dependencies to work, that are listed on the video_transcoding github page. Those are:

  • Ruby 2.x
  • HandBrake-CLI
  • ffmpeg
  • mkvtoolnix
  • mp4v2
  • mplayer

What we will get

  • some dependencies installed via apt-get
  • some installed dependencies installed via linuxbrew (As it often has current versions compared to repos)
  • video_transcoding installed via ruby gem (comparable to original manual)

Activating the linux subsystem for windows

To begin, go to security&updates -> for developers -> and change your computer to "developer mode".

Head into your search bar in windows and look for "windows-features" and you should find a control panel link getting you to a nice window where you can activate the "Windows-Subsystem for Linux (Beta)". When this is done, start your ubuntu shell (if you don't immediatly see a link, search for "ubuntu" in the search bar) and follow the instructions. When you're done, you should run

sudo apt-get update && sudo apt-get upgrade

to get your system up to date.

Let's first collect install all the ruby versions's we need

sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install ruby2.4
sudo apt-get install ruby1.9

and select ruby version 2.4 with

sudo update-alternatives --config ruby

Getting linuxbrew brewing

get the dependencies right:

sudo apt-get install build-essential curl git python-setuptools m4

and then actually install, as documented on the linuxbrew website in the "Install Linuxbrew (tl;dr)" section.

Proceed, when you have a partially working brew system. Note: You may have to insert a

. .bash_profile

inside your .bashrc, because on lxss, right now, .bash_profiles seem to be ignored.

You also will want to have your .bash_profile to look something alike:

export PATH="/home/justin/.linuxbrew/bin:$PATH"
export MANPATH="/home/justin/.linuxbrew/share/man:$MANPATH"
export INFOPATH="/home/justin/.linuxbrew/share/info:$INFOPATH"
export HOMEBREW_BUILD_FROM_SOURCE=1
export EDITOR="/usr/bin/nano"
export HOMEBREW_VERBOSE=1

I set the verbosityand build_from_source, because bottles currently don't work on lxss and installing something without verbose when compiling often makes it seem stuck when in reality, it is just still compiling.

The fun part with linuxbrew

Before you start, we need to trick a little:

sudo update-alternatives --config ruby

select the 1.9 version now. Now enter brew config - a lot of text from portable ruby should scroll through. We thereby force homebrew to use the portable ruby version isntead of the system one. After you've done that, issue sudo update-alternatives --config ruby again and change back to 2.4.

Now you should be able to run

brew update && brew upgrade

Some build dependencies depend on some other tools, that aren't marked as dependencies in them and you also need some things to get the ball rolling on lxss:

brew install m4 xz gettext gcc ffmpeg mkvtoolnix mp4v2 mplayer

Now grab a cup of coffee or tee or go in the Biergarten and drink a Maß and come back later the next day, it'll take some LONG time. ;-)

We need handbrake

The easiest way to obtain handbrake is from their ppa page, this means:

sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo apt-get update
sudo apt-get install handbrake-cli

Install video_transcoding

Nothing special here, just run:

sudo gem install video_transcoding

Caveats

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. It then should work.

I hope this works. If it doesn't, feel free to contact me on twitter @JMoVS or comment below. Don't comment below, I won't get a notification for it. Please rely on Twitter or write me an email at video_transcoding [AT] justinscholz.de .

@JMoVS
Copy link
Author

JMoVS commented Nov 14, 2016

@samhutchins No worries, I had to discover myself that one won't get notifications here...

I am out of ideas, the only thing I noticed is that your homebrew version is old (I have 1.0.7 here, whereas you have 1.0.6). But if it's not of importance for you, then that is ok for me as well. ;-)

Do you happen to have written down how you got the tools running natively/in Cygwin on Windows?

@samhutchins
Copy link

samhutchins commented Nov 15, 2016

@JMoVS
Never written down formally. One day I might

In overview though:

  1. Ruby from here
  2. Handbrake from here
  3. ffmpeg from here
  4. mkvtoolsnix from here
  5. mp4v2 from here
  6. MPlayer from here

Steps:

  1. Create C:\bin and add it to the PATH
  2. Copy the exes for ffmpeg, handbrakecli, mplayer, and mp4v2 to the bin directory (including the fonts directories, IIRC)
  3. Run installers for Ruby and mkvtoolsnix
  4. Make sure the install location for mkvtoolsnix is in the PATH (IIRC it isn't by default)
  5. Open CMD, check you can call the programs listed in Don Melton's requirements
  6. gem install video_transcoding

Then you can run the tools from CMD. I use Clink to make CMD less unbearable

No Cygwin in sight :-)

Lol

@krrlw
Copy link

krrlw commented Dec 1, 2016

FWIW, I have the same error as @samhutchins. Any solution yet?

@botsmack
Copy link

botsmack commented Dec 6, 2016

Also getting the same error on any attempt to install from brew.

/home/rwbash/.linuxbrew/Library/Homebrew/build.rb:191:in `dump': instance of IO needed (TypeError)
       from /home/rwbash/.linuxbrew/Library/Homebrew/build.rb:191:in `rescue in <main>'
       from /home/rwbash/.linuxbrew/Library/Homebrew/build.rb:180:in `<main>'
Error: Suspicious failure
HOMEBREW_VERSION: >1.1.0 (no git repository)
ORIGIN: https://github.com/Linuxbrew/brew
HEAD: 49b3fe150f015bd51cb0d1a430b5257b88739c38
Last commit: 13 hours ago
Core tap ORIGIN: https://github.com/Linuxbrew/homebrew-core
Core tap HEAD: 85b743ec4764deb3e3761bd293e2cd0bc5659ff2
Core tap last commit: 2 hours ago
HOMEBREW_PREFIX: /home/rwbash/.linuxbrew
HOMEBREW_REPOSITORY: /home/rwbash/.linuxbrew
HOMEBREW_CELLAR: /home/rwbash/.linuxbrew/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://linuxbrew.bintray.com
CPU: octa-core 64-bit nehalem
Homebrew Ruby: 2.2.5 => /usr/bin/ruby2.2
Clang: N/A
Git: 1.9.1 => /usr/bin/git
Perl: /usr/bin/perl
Python: /usr/bin/python => /usr/bin/python2.7
Ruby: /usr/bin/ruby => /usr/bin/ruby2.2
Java: N/A
Kernel: Linux 3.4.0+ x86_64 GNU/Linux
OS: Ubuntu 14.04.5 LTS
Codename: trusty
OS glibc: 2.19
OS gcc: 4.8.4
Linuxbrew glibc: N/A
Linuxbrew gcc: N/A
Linuxbrew xorg: N/A

@JMoVS
Copy link
Author

JMoVS commented Jan 16, 2017

yes, there is a fix. And I forgot to include one important line. It seems like the problem was that Ubuntu 14.04 LTS (shipped with windows) uses the old ruby. Even though you installed the new one, it wasn't linked. I added the line to the ruby section to actually change the used ruby.

@samhutchins
Copy link

Notes:

  • Installing ruby2.4 removes 1.9, you'll need to reinstall it
  • Don't run brew config twice, that seems to break linuxbrew for me
  • Need to install m4 (sudo apt-get install m4) or gmp won't build during the brew install... step

Other thoughts and opinions

I get that having all of this handled by a package manager is nice, but the cost of getting that seems high:

  • switching your computer to developer mode
  • enabling a beta feature of the OS
  • going through a really fragile set of hoops that could break at any moment, so that:
  • you can wait for several hours for all the dependencies to compile

For me, and I imagine many others, it's not a worthwhile tradeoff vs downloading native executables; especially when I basically never have to update the dependencies. The only thing I'd care to keep up to date is Handbrake, and that rarely updates. This whole setup is also really fragile, I feel like one wrong move could break everything. What if the next time I apt-get upgrade one of the ruby versions get removed?

Maybe in the Spring when Windows gets that big update the balance will change, but for now I think this is a needlessly complicated way to install video_transcoding and its dependencies.

To each their own though, this method works and it's amazing that Windows can do this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment