Difference between revisions of "HandBrake"

From Indie IT Wiki
 
(20 intermediate revisions by 2 users not shown)
Line 233: Line 233:
  
 
  sudo -i
 
  sudo -i
  wget http://us.download.nvidia.com/XFree86/Linux-x86_64/390.87/NVIDIA-Linux-x86_64-390.87.run
+
  <nowiki>wget http://us.download.nvidia.com/XFree86/Linux-x86_64/390.87/NVIDIA-Linux-x86_64-390.87.run</nowiki>
 
  sh ./NVIDIA-Linux-x86_64-390.87.run
 
  sh ./NVIDIA-Linux-x86_64-390.87.run
 
  exit
 
  exit
Line 258: Line 258:
  
 
  HandBrakeCLI --input /dev/dvd --main-feature --audio-lang-list eng '''--aencoder faac,copy:ac3''' --output "Quantum Of Solace (2008).mp4"
 
  HandBrakeCLI --input /dev/dvd --main-feature --audio-lang-list eng '''--aencoder faac,copy:ac3''' --output "Quantum Of Solace (2008).mp4"
 +
 +
== Single Audio Track Matching Language ==
 +
 +
--audio-lang-list eng --first-audio
 +
 +
For this, you cannot use a preset (at least, I couldn't get this to work when using a preset!) ...
 +
 +
'''Docker or Tdarr'''
 +
 +
'''720p'''
 +
 +
docker run --rm -v "/home/paully/:/storage:ro" -v "/home/paully/ToDo/HandBrake/config:/config:rw" -v "/home/paully/ToDo/HandBrake/watch:/watch:rw" -v "/home/paully/ToDo/HandBrake/output:/output:rw" jlesage/handbrake /usr/bin/HandBrakeCLI --input "/storage/data/media/movies/Movie Name (Year)/Movie Name (Year).mkv" --stop-at duration:60 --maxWidth 1280 --maxHeight 720 --quality 20 --encoder x264 --encoder-preset slow --encopts="vbv-bufsize=4000:vbv-maxrate=2000" --non-anamorphic --audio-lang-list eng --first-audio --aencoder ac3 --ab 384 --no-markers --subtitle none --output "/output/output.mp4"
 +
 +
'''1080p'''
 +
 +
docker run --rm -v "/home/paully/:/storage:ro" -v "/home/paully/ToDo/HandBrake/config:/config:rw" -v "/home/paully/ToDo/HandBrake/watch:/watch:rw" -v "/home/paully/ToDo/HandBrake/output:/output:rw" jlesage/handbrake /usr/bin/HandBrakeCLI --input "/storage/data/media/movies/Movie Name (Year)/Movie Name (Year).mkv" --stop-at duration:60 --maxWidth 1920 --maxHeight 1080 --quality 20 --encoder x265 --encoder-preset slow --encopts="vbv-bufsize=4000:vbv-maxrate=2000" --non-anamorphic --audio-lang-list eng --first-audio --aencoder copy --audio-copy-mask=aac,ac3,eac3,truehd,dts --no-markers --subtitle none --output /output/output.mkv
  
 
== Command Line Interface CLI ==
 
== Command Line Interface CLI ==
Line 264: Line 280:
  
 
https://forum.handbrake.fr/viewforum.php?f=10
 
https://forum.handbrake.fr/viewforum.php?f=10
 +
 +
== Set Maximum Bitrate ==
 +
 +
Set max bitrate to 1.5Mbps ...
 +
 +
--encopts="vbv-bufsize=3000:vbv-maxrate=1500"
  
 
== Script to Cycle Through Folder ==
 
== Script to Cycle Through Folder ==
  
This will cyle through the MKV files in a folder and output MP4 files. Just remove the .mkv if you have different sorts of files to batch process.
+
This will cyle through the MKV files in a folder and output MP4 files.
  
 
  #!/bin/bash
 
  #!/bin/bash
Line 342: Line 364:
  
 
  --two-pass --x264-preset slowest
 
  --two-pass --x264-preset slowest
 +
 +
'''October 2024'''
 +
 +
I'm coming back to HandBrake from ffpmeg in tandem with Tdarr.
 +
 +
This is my command line for a Full HD 1080p with ''just one'' E-AC3 Dolby Atmos audio passthrough (instead of the normal dual audio) ..
 +
 +
HandBrakeCLI --input "input.mkv" --preset "Super HQ 2160p60 4K HEVC Surround" --encoder x265 --non-anamorphic --audio 1 --aencoder copy:eac3 --no-markers --output "output.mkv"
 +
 +
== 4K UHD Transcode ==
 +
 +
https://handbrake.fr/docs/en/latest/technical/hdr.html
 +
 +
https://www.youtube.com/watch?v=v9QMdXQk7No
 +
 +
strong-intra-smoothing=0:rect=0:aq-mode=1:rd=4:psy-rd=0.75:psy-rdoq=4.0:rdoq-level=1:rskip=2
 +
 +
More info coming soon.
 +
 +
Matroska  (--format "av_mkv")
 +
Passthru common metadata  ()
 +
Resolution Limit 2160p 4K Ultra HD  ()
 +
H.265 10-bit  (--encoder "x265_10bit")
 +
Framerate same as source  ()
 +
Constant Framerate  (--cfr)
 +
Preset Slow  (--encoder-preset "slow")
 +
Tune None  ()
 +
Profile main10  (--encoder-profile "main10")
 +
Level 5.1  (--encoder-level "5.1")
 +
Constant Quality RF 24  (--crf "24")
 +
E-AC3 Passthrough  (--aencoder "copy:eac3")
 +
Subtitles Remove All  (--subtitle "none")
 +
No Chapter Markers  (--no-markers)
 +
 +
https://www.reddit.com/r/handbrake/comments/1g7c4sl/gui_to_cli_options_check/
 +
 +
=== Docker ===
 +
 +
So, this is the command line I ran using the Docker container, which came out beautifully :-)
 +
 +
Bearing in mind that the Audio track was E-AC3 Dolby Atmos so that's why I have had to chose 'E-AC3 Passthrough' or 'copy:eac3'.
 +
 +
If your movie source has TrueHD then you would choose 'True HD Passthrough' in the GUI or 'copy:truehd' in the CLI.
 +
 +
'''TIP: to change the Audio settings in the GUI you double-click on the line and use the drop-down to choose the 'Passthrough' options... yeah, not clear :)'''
 +
 +
docker run --rm -v "/home/user/:/storage:ro" -v "/home/user/ToDo/HandBrake/config:/config:rw" -v "/home/user/ToDo/HandBrake/watch:/watch:rw" -v "/home/user/ToDo/HandBrake/output:/output:rw" jlesage/handbrake /usr/bin/HandBrakeCLI --input "/storage/data/torrents/completed/movie.mkv" --stop-at duration:60 --preset "Super HQ 2160p60 4K HEVC Surround" --format "av_mkv" --encoder "x265_10bit" --encoder-preset "slow" --encoder-profile "main10" --encoder-level "5.1" --cfr --rate "24" --quality "24" --non-anamorphic --audio 1 --aencoder "copy:eac3" --subtitle "none" --no-markers --output "/output/movie_4k_test_cli.mkv"
 +
 +
=== HDR to SDR ===
 +
 +
primaries=bt709:transfer=bt709:matrix=bt709:tonemap=reinhard:desat=2
 +
 +
Full command line ...
 +
 +
720p x264 AC3 5.1
 +
 +
/usr/bin/HandBrakeCLI --input "input.mkv" --maxWidth "1280" --maxHeight "720" --format "av_mkv" --encoder "x264" --encoder-preset "slow" --cfr --rate "24" --quality "24" --non-anamorphic --colorspace "primaries=bt709:transfer=bt709:matrix=bt709:tonemap=reinhard:desat=2" --encopts "vbv-bufsize=4000:vbv-maxrate=2000" --audio-lang-list "eng" --first-audio --aencoder "ac3" --ab "384" --mixdown "5point1" --subtitle "none" --no-markers --output "output.mkv"
 +
 +
1080p x265 Dolby Atmos Passthrough
 +
 +
/usr/bin/HandBrakeCLI --input "input.mkv" --maxWidth "1920" --maxHeight "1080" --format "av_mkv" --encoder "x265" --encoder-preset "slow" --cfr --rate "24" --quality "20" --non-anamorphic --colorspace "primaries=bt709:transfer=bt709:matrix=bt709:tonemap=reinhard:desat=2" --encopts "vbv-bufsize=4000:vbv-maxrate=2000" --audio-lang-list "eng" --first-audio --aencoder "copy" --audio-copy-mask "aac,ac3,eac3,truehd,dts" --subtitle "none" --no-markers --output "output.mkv"
  
 
== Fix Missing Fribidi Libraries ==
 
== Fix Missing Fribidi Libraries ==
Line 382: Line 465:
 
  pip3 install --upgrade meson
 
  pip3 install --upgrade meson
 
  meson --version
 
  meson --version
  apt-get -y install libnuma1 libnuma-dev numactl
+
  apt-get -y install libnuma1 libnuma-dev libvpx-dev numactl
 
  ldconfig
 
  ldconfig
 
  exit
 
  exit

Latest revision as of 09:25, 15 November 2024

Adding Chapter Names Markers

Create a text CSV file with the lines as below...

1,Darts
2,Question Time
3,Gerald The Gorilla
4,Game For A Laugh
5,Are You A Gay Christian
6,Baronet Oswald Ernald Mosley
7,Origami
8,The Devil - Is He All Bad
9,Kinda Lingers
10,The Two Ninnies
11,Cut Off Their Goolies
12,Supa Dupa

Run the command line to include the markers option as below...

HandBrakeCLI --input input.mkv --markers="input.csv" --preset 'Fast 480p30' --non-anamorphic --encoder-preset slow --quality 22 --deinterlace --lapsharp --chapters 1-2 --output 'output.mp4'

This will give you a mediainfo output like the following...

Menu
ID                                       : 4
Codec ID                                 : text
Duration                                 : 1 h 38 min
Language                                 : English
Encoded date                             : UTC 2021-01-04 01:59:04
Tagged date                              : UTC 2021-01-04 01:59:04
Menu For                                 : 1,2,3
00:00:00.000                             : Darts
00:04:38.240                             : Question Time
00:16:43.520                             : Gerald The Gorilla
00:25:33.760                             : Game For A Laugh
00:32:50.400                             : Are You A Gay Christian
00:35:06.240                             : Baronet Oswald Ernald Mosley
00:52:01.440                             : Origami
01:00:50.880                             : The Devil - Is He All Bad
01:10:40.320                             : Kinda Lingers
01:15:09.440                             : The Two Ninnies
01:23:06.080                             : Cut Off Their Goolies
01:35:19.200                             : Supa Dupa

Then you will able to jump to a particular chapter with a better idea of what is chosen.

This is particularly good for music videos, with the chapter names as the song titles :-)

Movie Qualities

  • 576p x264 aac (2 channels 160 kbps)
  • 720p x264 ac3 (6 channels 384 kbps)
  • 1080p x265 dts (6 channels 1500 kbps)

Picture Quality

https://handbrake.fr/docs/en/latest/workflow/adjust-quality.html

Capture Log

To capture HandBrake’s log messages to a file, simply redirect stderr:

HandBrakeCLI ... 2> hb-log.txt

HEVC H.265 X265

https://www.techspot.com/article/1131-hevc-h256-enconding-playback/page7.html

Single AC3 audio 1080p...

"/usr/local/bin/HandBrakeCLI" --input "input.mkv" --main-feature --crop 0:0:0:0 --encoder x265 --encoder-preset medium --quality 22 --audio-lang-list eng --first-audio --aencoder ac3 --ab 384 --mixdown 5point1 --output "output hb x265 1080p ac3.mp4"

Dual audio 720p...

/usr/bin/HandBrakeCLI --input "input.mkv" --main-feature --chapters 1 --maxWidth 1280 --maxHeight 720 --crop 0:0:0:0 --markers --encoder x265 --encoder-preset medium --audio 1,1 --aencoder faac,ac3 --ab 160,384 --output "output.mp4"

Single AAC audio 720p...

/usr/bin/HandBrakeCLI --input "input.mkv" --main-feature --chapters 1 --maxWidth 1280 --maxHeight 720 --crop 0:0:0:0 --markers --encoder x265 --encoder-preset medium --audio 1 --aencoder av_aac --ab 384 --output "output.mp4"

Possible --encopts ...

pmode:rd=4:tu-intra-depth=3:rdoq-level=2:early-skip:b-intra:limit-modes:aq-mode=2:aq-strength=1.0:qg-size=16:ipratio=1.38:pbratio=1.28:me=3:max-merge=3:weightb:bframes=6:rc-lookahead=50:ref=6:psy-rdoq=1.38:no-sao
X264 X265 TIMINGS AND SIZES
ENCODER CPU ASM * NVENC ** SOURCE DISC PRESET RESOLUTION QUALITY AUDIO SIZE TIME
x265 25% no no 21Gb BD medium 1080p 22 ac3 1.9Gb 86 hours
x264 25% no no 21Gb BD veryslow 720p 22 ac3 1.4Gb 18 hours
x264 50% no no 21Gb BD veryslow 720p 22 ac3 1.4Gb 6 hours
x264 50% no no 6Gb DVD veryslow 576p 22 ac3 1.0Gb 4 hours
x265 50% no no 21Gb BD medium 1080p 22 ac3 1.9Gb 43 hours
x265 50% no no 22Gb BD medium 1080p 22 dts 2.2Gb 43 hours
x265 75% yes no 26Gb BD medium 1080p 22 dts 4.1Gb 14 hours
h265 75% yes yes 26Gb BD medium 1080p 22 dts 19Gb 1 hour

* ASM is the technology which uses the CPU's built-in features and flags such as MMX, etc. I realised that I was not using them!

** NVENC - NVidiaENCoding using a GTX1050 graphics video card... TO COME ;-)

HOW TO FIX CPU CAPABILITIES NONE

x265 [info]: using cpu capabilities: none!

https://bitbucket.org/multicoreware/x265/src/tip/build/README.txt?at=default&fileviewer=file-view-default

UPDATE - 20181006 - After recompiling nasm 2.13.03 by hand, and recompiling x265 it now shows the correct CPU flags which it detects...

x265 --version
x265 [info]: HEVC encoder version 2.9
x265 [info]: build info [Linux][GCC 5.4.0][64 bit] 8bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX XOP FMA4 FMA3 BMI1

HOW TO NVENC

Blacklist the built-in Ubuntu Nouveau driver...

sudo rmmod nouveau
sudo echo "blacklist nouveau" >>/etc/modprobe.d/blacklist.conf

Download and install the latest official stable Nvidia drivers for Linux...

Latest Long Lived Branch version: 390.87

sudo -i
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/390.87/NVIDIA-Linux-x86_64-390.87.run
sh ./NVIDIA-Linux-x86_64-390.87.run
exit

Change the encoder option for HandBrake...

/usr/local/bin/HandBrakeCLI --input input.mkv --main-feature --no-markers --crop 0:0:0:0 --encoder nvenc_h265 --encoder-preset medium --quality 22 --audio 2 --aencoder copy:dts --subtitle none --output output.mp4

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"

Single Audio Track Matching Language

--audio-lang-list eng --first-audio

For this, you cannot use a preset (at least, I couldn't get this to work when using a preset!) ...

Docker or Tdarr

720p

docker run --rm -v "/home/paully/:/storage:ro" -v "/home/paully/ToDo/HandBrake/config:/config:rw" -v "/home/paully/ToDo/HandBrake/watch:/watch:rw" -v "/home/paully/ToDo/HandBrake/output:/output:rw" jlesage/handbrake /usr/bin/HandBrakeCLI --input "/storage/data/media/movies/Movie Name (Year)/Movie Name (Year).mkv" --stop-at duration:60 --maxWidth 1280 --maxHeight 720 --quality 20 --encoder x264 --encoder-preset slow --encopts="vbv-bufsize=4000:vbv-maxrate=2000" --non-anamorphic --audio-lang-list eng --first-audio --aencoder ac3 --ab 384 --no-markers --subtitle none --output "/output/output.mp4"

1080p

docker run --rm -v "/home/paully/:/storage:ro" -v "/home/paully/ToDo/HandBrake/config:/config:rw" -v "/home/paully/ToDo/HandBrake/watch:/watch:rw" -v "/home/paully/ToDo/HandBrake/output:/output:rw" jlesage/handbrake /usr/bin/HandBrakeCLI --input "/storage/data/media/movies/Movie Name (Year)/Movie Name (Year).mkv" --stop-at duration:60 --maxWidth 1920 --maxHeight 1080 --quality 20 --encoder x265 --encoder-preset slow --encopts="vbv-bufsize=4000:vbv-maxrate=2000" --non-anamorphic --audio-lang-list eng --first-audio --aencoder copy --audio-copy-mask=aac,ac3,eac3,truehd,dts --no-markers --subtitle none --output /output/output.mkv

Command Line Interface CLI

https://handbrake.fr/docs/en/1.3.0/cli/command-line-reference.html

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

Set Maximum Bitrate

Set max bitrate to 1.5Mbps ...

--encopts="vbv-bufsize=3000:vbv-maxrate=1500"

Script to Cycle Through Folder

This will cyle through the MKV files in a folder and output MP4 files.

#!/bin/bash
SRC="/path/to/input folder"
DEST="/path/to/output folder"
DEST_EXT=mp4
HANDBRAKE_CLI="/usr/local/bin/HandBrakeCLI"
HANDBRAKE_OPTIONS="--width 720 --height 576 --non-anamorphic --crop 0:0:0:0 --encoder x264 --encoder-preset veryslow --deinterlace --no-markers"
for FILE in "$SRC"/*.mkv
do
   filename=$(basename "${FILE}")
   extension=${filename##*.}
   filename=${filename%.*}
   echo "${HANDBRAKE_CLI} --input \""${FILE}"\" "${HANDBRAKE_OPTIONS}" --output \""${DEST}"/"${filename}".${DEST_EXT}\""
   #{HANDBRAKE_CLI} --input "${FILE}" ${HANDBRAKE_OPTIONS} --output "${DEST}"/"${filename}".${DEST_EXT}
done
exit

Latest Goalpost Moving X264 Command Line Settings

February 2017

/usr/bin/HandBrakeCLI --input "input.mkv" --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 Deinterlacing

Some of the older DVDs have the Interlacing scan type.

Scan type                                : Interlaced

When you use HandBrake to convert them in to smaller files, they will need to be run through the 'deinterlace' filter first otherwise you will get horrible combing effects.

HandBrakeCLI --input "file.mkv" --width 720 --height 576 --non-anamorphic --crop 0:0:0:0 --encoder x264 --encoder-preset placebo --deinterlace --no-markers --output "file.mp4"

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

October 2024

I'm coming back to HandBrake from ffpmeg in tandem with Tdarr.

This is my command line for a Full HD 1080p with just one E-AC3 Dolby Atmos audio passthrough (instead of the normal dual audio) ..

HandBrakeCLI --input "input.mkv" --preset "Super HQ 2160p60 4K HEVC Surround" --encoder x265 --non-anamorphic --audio 1 --aencoder copy:eac3 --no-markers --output "output.mkv"

4K UHD Transcode

https://handbrake.fr/docs/en/latest/technical/hdr.html

https://www.youtube.com/watch?v=v9QMdXQk7No

strong-intra-smoothing=0:rect=0:aq-mode=1:rd=4:psy-rd=0.75:psy-rdoq=4.0:rdoq-level=1:rskip=2

More info coming soon.

Matroska   (--format "av_mkv")
Passthru common metadata   ()
Resolution Limit 2160p 4K Ultra HD   ()
H.265 10-bit   (--encoder "x265_10bit")
Framerate same as source   ()
Constant Framerate   (--cfr)
Preset Slow   (--encoder-preset "slow")
Tune None   ()
Profile main10   (--encoder-profile "main10")
Level 5.1   (--encoder-level "5.1")
Constant Quality RF 24   (--crf "24")
E-AC3 Passthrough   (--aencoder "copy:eac3")
Subtitles Remove All   (--subtitle "none")
No Chapter Markers   (--no-markers)

https://www.reddit.com/r/handbrake/comments/1g7c4sl/gui_to_cli_options_check/

Docker

So, this is the command line I ran using the Docker container, which came out beautifully :-)

Bearing in mind that the Audio track was E-AC3 Dolby Atmos so that's why I have had to chose 'E-AC3 Passthrough' or 'copy:eac3'.

If your movie source has TrueHD then you would choose 'True HD Passthrough' in the GUI or 'copy:truehd' in the CLI.

TIP: to change the Audio settings in the GUI you double-click on the line and use the drop-down to choose the 'Passthrough' options... yeah, not clear :)

docker run --rm -v "/home/user/:/storage:ro" -v "/home/user/ToDo/HandBrake/config:/config:rw" -v "/home/user/ToDo/HandBrake/watch:/watch:rw" -v "/home/user/ToDo/HandBrake/output:/output:rw" jlesage/handbrake /usr/bin/HandBrakeCLI --input "/storage/data/torrents/completed/movie.mkv" --stop-at duration:60 --preset "Super HQ 2160p60 4K HEVC Surround" --format "av_mkv" --encoder "x265_10bit" --encoder-preset "slow" --encoder-profile "main10" --encoder-level "5.1" --cfr --rate "24" --quality "24" --non-anamorphic --audio 1 --aencoder "copy:eac3" --subtitle "none" --no-markers --output "/output/movie_4k_test_cli.mkv"

HDR to SDR

primaries=bt709:transfer=bt709:matrix=bt709:tonemap=reinhard:desat=2

Full command line ...

720p x264 AC3 5.1

/usr/bin/HandBrakeCLI --input "input.mkv" --maxWidth "1280" --maxHeight "720" --format "av_mkv" --encoder "x264" --encoder-preset "slow" --cfr --rate "24" --quality "24" --non-anamorphic --colorspace "primaries=bt709:transfer=bt709:matrix=bt709:tonemap=reinhard:desat=2" --encopts "vbv-bufsize=4000:vbv-maxrate=2000" --audio-lang-list "eng" --first-audio --aencoder "ac3" --ab "384" --mixdown "5point1" --subtitle "none" --no-markers --output "output.mkv"

1080p x265 Dolby Atmos Passthrough

/usr/bin/HandBrakeCLI --input "input.mkv" --maxWidth "1920" --maxHeight "1080" --format "av_mkv" --encoder "x265" --encoder-preset "slow" --cfr --rate "24" --quality "20" --non-anamorphic --colorspace "primaries=bt709:transfer=bt709:matrix=bt709:tonemap=reinhard:desat=2" --encopts "vbv-bufsize=4000:vbv-maxrate=2000" --audio-lang-list "eng" --first-audio --aencoder "copy" --audio-copy-mask "aac,ac3,eac3,truehd,dts" --subtitle "none" --no-markers --output "output.mkv"

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

sudo apt-get install snapd
sudo snap install cmake --classic

ERROR: Could not detect Ninja v1.5 or newer

sudo -i
pip3 install --upgrade ninja
exit

YES

NOW USING SELF COMPILED X264, X265, FDK-AAC LIBARIES

https://handbrake.fr/docs/en/latest/developer/build-linux.html

sudo -i
apt-get install autoconf automake build-essential cmake git libass-dev libbz2-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libharfbuzz-dev libjansson-dev liblzma-dev libmp3lame-dev libogg-dev libopus-dev libsamplerate-dev libspeex-dev libtheora-dev libtool libtool-bin libvorbis-dev libxml2-dev m4 make nasm patch pkg-config python tar yasm zlib1g-dev libturbojpeg0-dev libjpeg-turbo8 libjpeg-turbo8-dev libvpx5 libvpx-dev
apt-get install python3
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
pip3 install --upgrade pip
pip3 install --upgrade ninja
ninja --version
pip3 install --upgrade meson
meson --version
apt-get -y install libnuma1 libnuma-dev libvpx-dev numactl
ldconfig
exit
cd ~/Downloads
git clone https://github.com/HandBrake/HandBrake
cd HandBrake/
git pull
sudo ldconfig
make clean
./configure --force --verbose --launch-jobs=$(nproc) --launch --disable-gtk --enable-x265 --enable-fdk-aac
sudo make --directory=build install
HandBrakeCLI --version
HandBrakeCLI --help

To uninstall...

cd ~/Downloads/HandBrake
sudo make --directory=build uninstall


NO

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


OLD

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 - instead 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 
#!/bin/bash
/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*

Make Movies Louder

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

HandBrakeCLI --help
       --gain <float>      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.