HandBrake

Subtitles
To add all the English subtitles...

HandBrakeCLI --input /dev/dvd --main-feature --audio-lang-list eng --aencoder faac,ac3 --ab 160,384 --subtitle-lang-list eng --all-subtitles --output "movie.mp4"

To add just the forced subtitles for the foreign speaking parts of a movie...

HandBrakeCLI --input /dev/dvd --main-feature --audio-lang-list eng --aencoder faac,ac3 --ab 160,384 --subtitle scan --subtitle-forced --native-language eng --output "movie.mp4"

Multiple Audio Tracks
If you transcode your movie with multiple audio tracks, then it will solve the problem of missing audio... because the old TV you are using with automatically use AAC Stereo 2 Channels, rather than AC-3 Surround 6 Channels. This works very well with Plex.

Below is an example which reads the DVD, selects the movie, makes sure we have the English audio track, create multiple audio tracks in AAC Stereo 2 Channels + copy the AC-3 (lossless) and output the file name with the correct naming format for Plex...

HandBrakeCLI --input /dev/dvd --main-feature --audio-lang-list eng --aencoder faac,copy:ac3 --output "Quantum Of Solace (2008).mp4"

Command Line Interface CLI
https://trac.handbrake.fr/wiki/CLIGuide

https://forum.handbrake.fr/viewforum.php?f=10

Latest Goalpost Moving X264 Command Line Settings
February 2017

/usr/bin/HandBrakeCLI --input "input.mkv" --main-feature --maxWidth 1280 --maxHeight 720 --crop 0:0:0:0 --markers --encoder x264 --encoder-preset veryslow --encoder-tune film --encoder-profile high --encoder-level 3.1 --audio 1,1 --aencoder faac,ac3 --ab 160,384 --output "output.mp4"

https://handbrake.fr/docs/en/1.0.0/cli/cli-guide.html

Logging
HandBrakeCLI commands and options 2>/tmp/hb.log

https://trac.handbrake.fr/wiki/ActivityLogCLI

ffmpeg avconv CheatSheet
http://www.rodrigopolo.com/ffmpeg/cheats.php

DVD Transcode
Converting an ISO file to a standard definition 720x576 Matroska video file, keeping the 1024x576 display aspect, chapters and subtitles.

time HandBrakeCLI --input ~/Videos/Film.iso --encoder x264 --quality 18 --title 1 --audio 1 --aencoder copy --subtitle 1 --crop 0:0:0:0 --markers --custom-anamorphic --keep-display-aspect --output ~/Videos/Film.mkv

Blu-Ray Transcode
Find the correct (probably AC-3) audio track...

HandBrakeCLI --input "Movie.mkv" --title 0

Converting a Full HD Matroska video file to an Normal HD 1280x720 MP4 video file, x264 slow speed, no subtitles, with dual audio tracks from the first (and possibly only) audio track, tuned for an normal live action movie. This will take about 8 hours to encode...

HandBrakeCLI --input "movie.mkv" --main-feature --maxWidth 1280 --maxHeight 720 --crop 0:0:0:0 --markers --x264-preset slow --x264-tune film --audio 1,1 --aencoder faac,ac3 --ab 160,384 --subtitle none --output "movie.mp4"

Converting a Full HD Matroska video file to an Normal HD 1280x720 MP4 video file, x264 medium speed, no subtitles, with dual audio tracks, tuned for an animated movie. This will take about 6 hours to encode...

HandBrakeCLI --input "movie.mkv" --main-feature --maxWidth 1280 --maxHeight 720 --crop 0:0:0:0 --markers --x264-preset medium --x264-tune animation --audio 2,2 --aencoder faac,ac3 --ab 160,384 --subtitle none --output "movie.mp4"

The slower you can go, the better.

--x264-preset slowest

...will probably take about 12 hours to encode... but be stunning.

If you went one stage further and did 2-pass, then it would probably take about 24 hours to encode!

--two-pass --x264-preset slowest

Fix Missing Fribidi Libraries
HandBrake now requires the Fribidi Libraries, and so you need to install them in order to compile HandBrake.

Ubuntu

sudo apt-get install libfribidi-dev

Gentoo

emerge dev-libs/fribidi

Keeping Up To Date
NEWER

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

Thanks - https://handbrake.fr/docs/en/1.0.0/get-handbrake/download-and-install.html

NEW

sudo apt-get install build-essential cd ~/Downloads wget http://www.digip.org/jansson/releases/jansson-2.9.tar.gz tar -xzvf jansson-2.9.tar.gz cd jansson-2.9/ ./configure make sudo make install sudo ldconfig cd ~/Downloads git clone https://github.com/HandBrake/HandBrake cd HandBrake/ git pull ./configure --force --launch --disable-gtk cd build/ sudo make install HandBrakeCLI --help

The wonderful software HandBrake only gets official releases once a year. In computing terms, this is a lifetime and all those marvellous advances in video jiggerypokery will be lost.

So, we install the latest SVN version that the programmers are working on today!

**UPDATE** But first we need some development libraries from the Ubuntu repositories:-

sudo apt-get install --yes libass-dev libtheora-dev libvorbis-dev libsamplerate0-dev

Now, we can install HandBrake...

cd ~/Downloads rm -rf hb-trunk svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk cd hb-trunk rm -rf build/ ./configure --force --launch --disable-gtk cd build/ sudo make install

That's it! This will install the 12Mb binary file into /usr/local/bin/HandBrakeCLI

To test you have it working...

HandBrakeCLI --update

...and you will see the SVN version number...

[22:51:04] hb_init: checking for updates [22:51:04] Using http://handbrake.fr/appcast_unstable.xml [22:51:04] latest: 0.9.8 i686, build 2012071700 [22:51:05] hb_init: starting libhb thread HandBrake svn5086 (2012112801) - Linux x86_64 - http://handbrake.fr Your version of HandBrake is up to date.

Enjoy!

Gentoo Linux Installation
su - root cd emerge -q dev-libs/fribidi svn checkout svn://svn.handbrake.fr/HandBrake/trunk hb-trunk cd hb-trunk WANT_AUTOMAKE="1.11" ./configure --launch --disable-gtk --force cd build/ sudo make install

Limit CPU Usage On HandBrake
Install the package cpulimit... sudo apt-get install cpulimit

Now you can limit the cpu usage by specifying the exact program name and the total percentage amount of all cores. The example below limits the cpu to a total usage of 80% (which is 20% each x 4 cores) for the program called HandBrakeCLI...

sudo cpulimit -e HandBrakeCLI -l80

Note this will dramatically increase the time for transcoding - instaed of taking 2 minutes it took 10 minutes... but at least it kept the cpu from overheating! :-)

paully@mythbuntu-server3:~$ cat /etc/init.d/cpulimit.sh /usr/bin/cpulimit -b -e HandBrakeCLI -l 80 &>/dev/null /usr/bin/cpulimit -b -e avconv -l 80 &>/dev/null /usr/bin/cpulimit -b -e mencoder -l 80 &>/dev/null /etc/rc2.d/S10cpulimit.sh -> /etc/init.d/cpulimit.sh*
 * 1) !/bin/bash

Make Movies Louder
Use the new --gain option to increase the volume during transcoding...

HandBrakeCLI --help

--gain     Amplify or attenuate audio before encoding. Does NOT work with audio passthru (copy). Values are in                           dB. Negative values attenuate, positive values amplify. A 1 dB difference is barely audible.