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 .

@samhutchins
Copy link

samhutchins commented Oct 12, 2016

Hi @JMoVS

The error I get on brew install xz gettext

==> Installing dependencies for gettext: pkg-config, homebrew/dupes/ncurses
==> Installing gettext dependency: pkg-config
/home/sam/.linuxbrew/Library/Homebrew/build.rb:189:in `dump': instance of IO needed (TypeError)
        from /home/sam/.linuxbrew/Library/Homebrew/build.rb:189:in `rescue in <main>'
        from /home/sam/.linuxbrew/Library/Homebrew/build.rb:178:in `<main>'
Error: Suspicious failure

Having only minimal experience with homebrew limits my ability to debug this, but if you have any insight I'd welcome it :-D

Copy link

ghost commented Oct 15, 2016

The above error is a bug in Linuxbrew when running under Ubuntu bash for Windows

Linuxbrew/brew#98

@JMoVS
Copy link
Author

JMoVS commented Oct 17, 2016

Hi @samhutchins ,

sorry for the slow reply! Somehow, github didn't email notify me of your comment -.-

Could you paste the output of brew doctor and brew config here?
And maybe run brew install pgk-config -v so we get a better idea of whether it's a brew error or a package error? Does installing any other package work?

@samhutchins
Copy link

TIL: never rely on GitHub notifications. Many apologies for not getting back to you sooner

Brew doctor:

sam@CORUSCANT:~$ brew doctor
Your system is ready to brew.

Brew config

sam@CORUSCANT:~$ brew config
HOMEBREW_VERSION: 1.0.6
ORIGIN: https://github.com/Linuxbrew/brew
HEAD: d782b6a1ca553a6688a63da7003f3500c1ca5131
Last commit: 6 weeks ago
Core tap ORIGIN: https://github.com/Linuxbrew/homebrew-core
Core tap HEAD: 80aad1f193c3b8f407319d833ddd680ba5f667ed
Core tap last commit: 5 weeks ago
HOMEBREW_PREFIX: /home/sam/.linuxbrew
HOMEBREW_REPOSITORY: /home/sam/.linuxbrew
HOMEBREW_CELLAR: /home/sam/.linuxbrew/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://linuxbrew.bintray.com
CPU: quad-core 64-bit haswell
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

brew install pkg-config -v:

sam@CORUSCANT:~$ brew install pkg-config -v
Checking if we need to fetch /home/sam/.linuxbrew...
Checking if we need to fetch /home/sam/.linuxbrew/Library/Taps/homebrew/homebrew-core...
Checking if we need to fetch /home/sam/.linuxbrew/Library/Taps/homebrew/homebrew-dupes...
Fetching /home/sam/.linuxbrew...
Fetching /home/sam/.linuxbrew/Library/Taps/homebrew/homebrew-core...
Fetching /home/sam/.linuxbrew/Library/Taps/homebrew/homebrew-dupes...
Updating /home/sam/.linuxbrew...
Reset branch 'stable'
Current branch stable is up to date.

Updating /home/sam/.linuxbrew/Library/Taps/homebrew/homebrew-core...
First, rewinding head to replay your work on top of it...
Fast-forwarded master to origin/master.

Updating /home/sam/.linuxbrew/Library/Taps/homebrew/homebrew-dupes...
First, rewinding head to replay your work on top of it...
Fast-forwarded master to origin/master.

==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core, homebrew/dupes).
==> New Formulae
amqp-cpp            dbhash              libsquish           piknik              sqldiff             typescript
archi-steam-farm    git-series          locateme            pyinvoke            ssh-audit           yarn
armor               gitless             modd                questdb             svgcleaner
borg                hana                nmh                 rmlint              termbox
consul-backinator   hesiod              nvc                 sonar-scanner       terragrunt
csvtomd             jumanpp             osrm-backend        sql-translator      ttyd
==> Updated Formulae
abi-compliance-checker        freetds                       libnotify                     prometheus
ace                           fwup                          libosinfo                     protobuf-swift
afl-fuzz                      fzf                           libphonenumber                purescript
aha                           gammaray                      libpointing                   pushpin
allegro                       gammu                         librasterlite                 pyqt5
ammonite-repl                 gauche                        libsoup                       python
android-ndk                   gauge                         libspatialite                 python3
ansible-cmdb                  gdal                          libssh2                       qca
ansiweather                   gdb                           libtorrent-rasterbar          qjackctl
antigen                       gdk-pixbuf                    libuv                         qscintilla2
apache-flink                  geckodriver                   libvirt                       qt5
apache-spark                  gedit                         libxmp                        qwt
apktool                       ghex                          linkerd                       re2
aqbanking                     git                           liquibase                     redpen
aria2                         git-archive-all               llnode                        remctl
artifactory                   git-credential-manager        llvm                          riemann-client
asciinema2gif                 git-extras                    logtalk                       ripgrep
asciiquarium                  git-lfs                       luaradio                      rocksdb
aubio                         gitbucket                     lynis                         rolldice
aurora-cli                    gitlab-ci-multi-runner        macvim                        roswell
autoenv                       glib                          mailhog                       rswift
autojump                      glib-networking               mapnik                        rtags
avro-c                        glide                         mapserver                     rtv
aws-elasticbeanstalk          gnome-builder                 mariadb                       ruby
aws-sdk-cpp                   gnome-icon-theme              matlab2tikz                   rush
awscli                        gnome-themes-standard         media-info                    rust
azure-cli                     gnumeric                      mediaconch                    s-search
b2-tools                      gnuplot                       mercurial                     scw
bash-git-prompt               gnutls                        meson                         selenium-server-standalone
bazel                         go                            metabase                      sflowtool
bear                          gobject-introspection         metaproxy                     shadowsocks-libev
bgpq3                         gofabric8                     mg3a                          shairport-sync
bind                          goffice                       micro                         shared-mime-info
binwalk                       googler                       micropython                   shellcheck
bitrise                       gosu                          midnight-commander            shyaml
boost                         gprof2dot                     minio                         sift
boost-bcp                     grails                        minio-mc                      sleuthkit
boost-python                  grib-api                      mitmproxy                     sonarqube
bsdconv                       gsettings-desktop-schemas     mkvtoolnix                    source-highlight
buku                          gsoap                         mlogger                       spatialite-gui
caddy                         gssdp                         mogenerator                   spatialite-tools
caf                           gstreamermm                   monetdb                       sqlite
cake                          gtk+3                         mongodb                       sqlite-analyzer
carthage                      gtkextra                      mongoose                      sqlmap
cask                          gtkmm3                        monit                         ssdb
castxml                       gucharmap                     monkeysphere                  sshguard
cayley                        gupnp                         mono                          ssllabs-scan
cern-ndiff                    gupnp-av                      mpv                           sslyze
certbot                       gwyddion                      msktutil                      strongswan
chaiscript                    gx                            mutt                          svtplay-dl
chapel                        gx-go                         mvtools                       syncthing
checkstyle                    hh                            mypy                          sysdig
chromedriver                  homebank                      mysql                         taglib
cjdns                         homebrew/dupes/file-formula   natalie                       tailor
clearlooks-phenix             homebrew/dupes/nano           ncmpcpp                       tcpkali
cli53                         homebrew/dupes/whois          neofetch                      terminal-notifier
clutter-gtk                   hub                           nettle                        terraform
cocoapods                     hugo                          nexus                         texmath
codequery                     i2p                           nghttp2                       tile38
collectd                      ice                           nginx                         tin
commandbox                    imagemagick                   nim                           tippecanoe
conan                         imapsync                      nmap                          titan-server
convox                        influxdb                      node                          tmux
cppcheck                      ipfs                          node-build                    tomcat
cpprestsdk                    irrlicht                      noti                          tor
creduce                       isc-dhcp                      notmuch                       torsocks
cromwell                      jack                          nspr                          uhd
crystal-lang                  jansson                       nvm                           unbound
cucumber-cpp                  jbake                         nzbget                        uwsgi
dar                           jboss-forge                   offlineimap                   vala
dbus                          jdk                           oniguruma                     valgrind
dcmtk                         jemalloc                      open-babel                    vapoursynth
debianutils                   jenkins                       openconnect                   vault
deheader                      jetty                         opencsg                       vcdimager
diff-pdf                      jfrog-cli-go                  openhmd                       vdirsyncer
digdag                        jsdoc3                        openshift-cli                 verilator
djview4                       jsoncpp                       osm2pgsql                     vim
docker                        jsonnet                       osquery                       voltdb
docker-compose                jsonpp                        oysttyer                      vultr
docker-machine-nfs            kapacitor                     p11-kit                       weboob
doctl                         kerl                          packer                        wgetpaste
dspdfviewer                   kettle                        paperkey                      wimlib
dvm                           khal                          passenger                     wine
efl                           khard                         passpie                       winetricks
eigen                         knot                          pazpar2                       wireshark
elasticsearch                 kobalt                        pcap_dnsproxy                 wxmac
elixir                        kube-aws                      pdal                          x265
elixirscript                  kubernetes-cli                pdf2htmlex                    xcenv
emacs-clang-complete-async    latex2html                    pdftoedn                      xonsh
evince                        ldc                           peco                          yank
exim                          ldns                          pgroonga                      yaz
fabio                         ledger                        pgrouting                     yazpp
fabric                        lfe                           pick                          you-get
fastd                         libass                        picocom                       youtube-dl
fdupes                        libcddb                       plantuml                      zile
ffmbc                         libcdio                       pngcrush                      zimg
ffmpeg                        libgaiagraphics               poco                          zplug
ffms2                         libgee                        ponyc                         zsh-autosuggestions
file-roller                   libgeotiff                    poppler                       zsh-completions
flex                          libgit2                       postgis                       zsh-navigation-tools
folly                         libiscsi                      pre-commit                    zsh-syntax-highlighting
fontforge                     libjson-rpc-cpp               premake                       zstd
fonttools                     liblwgeom                     profanity
freeipmi                      libmongoclient                progress
freeling                      libnfs                        proj
==> Renamed Formulae
stash-cli -> atlassian-cli
==> Deleted Formulae
automoc4                evas-generic-loaders    libmarisa               qbzr                    sonar-runner
cuty_capt               ezlupdate               puddletag               qwtpolar                sqliteman
dwarf                   frescobaldi             pyside                  rcssserver              treeline
elementary              jsdoc-toolkit           pyside-tools            shiboken                valkyrie

/home/sam/.linuxbrew/Library/Homebrew/build.rb:189:in `dump': instance of IO needed (TypeError)
        from /home/sam/.linuxbrew/Library/Homebrew/build.rb:189:in `rescue in <main>'
        from /home/sam/.linuxbrew/Library/Homebrew/build.rb:178:in `<main>'
Error: Suspicious failure

I'm not too bothered to get this working for me to be honest, I've got the tools running perfectly well native to Windows. I only tried this out of idle curiosity.

@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