LinuxCommandLibrary

handbrakecli

Convert video from one format to another

TLDR

Convert a video file to MKV (AAC 160kbit audio and x264 CRF20 video)

$ handbrakecli --input [input.avi] --output [output.mkv] --encoder x264 --quality 20 --ab 160
copy

Resize a video file to 320x240
$ handbrakecli --input [input.mp4] --output [output.mp4] --width 320 --height 240
copy

List available presets
$ handbrakecli --preset-list
copy

Convert an AVI video to MP4 using the Android preset
$ handbrakecli --preset="Android" --input [input.ext] --output [output.mp4]
copy

Print the content of a DVD, getting the CSS keys in the process
$ handbrakecli --input [/dev/sr0] --title 0
copy

Rip the first track of a DVD in the specified device. Audiotracks and subtitle languages are specified as lists
$ handbrakecli --input [/dev/sr0] --title 1 --output [out.mkv] --format av_mkv --encoder x264 --subtitle [1,4,5] --audio [1,2] --aencoder copy --quality [23]
copy

SYNOPSIS

HandBrakeCLI [options] -i -o

PARAMETERS

-i
    Specifies the input video file or directory.

-o
    Specifies the output file name and location.

-Z, --preset
    Uses a built-in or custom preset for encoding settings.

--preset-import
    Imports a custom preset file.

-e, --encoder
    Specifies the video encoder (e.g., x264, x265).

-q, --quality
    Sets the video quality using a constant quality value (RF). Lower values mean better quality.

-b, --vb
    Specifies the video bitrate in kbps.

-r, --rate
    Sets the video frame rate.

--width
    Sets the output video width.

--height
    Sets the output video height.

-a, --audio
    Specifies audio track and encoding parameters.

-s, --subtitle
    Specifies subtitle track and burn-in options.

-m, --markers
    Enable chapter markers

--start-at :
    Specifies where to start encoding at.

--stop-at :
    Specifies where to stop encoding at.

--crop
    Specifies the crop values to remove black borders.

-v, --verbose
    Increases verbosity.

-h, --help
    Displays help information.

DESCRIPTION

handbrakecli is a command-line interface for HandBrake, a versatile open-source video transcoder. It allows you to convert video files from almost any format to a selection of modern, widely supported codecs. HandBrake supports various input sources including DVDs, Blu-rays, and other video files.

handbrakecli enables you to automate video transcoding tasks, making it ideal for batch processing, scripting, and integrating into larger workflows. It offers granular control over encoding settings such as video and audio codecs, bitrates, frame rates, resolution, filters, and container formats. It is a powerful tool for users who need to perform repetitive transcoding operations efficiently and with fine-grained control, without a graphical user interface. The command-line nature also makes it especially suited for use on servers or other headless systems.

CAVEATS

Careful consideration should be given to selecting appropriate encoding parameters for desired output quality and file size. Incorrect parameters can result in poor video quality or excessively large files. Encoding is CPU intensive, and the time it takes depends on the source video, selected parameters, and available CPU resources.

ENCODING PRESETS

Using encoding presets (-Z option) is highly recommended for achieving good results without needing to understand every individual parameter. You can create your own presets using the GUI version of HandBrake and then import them for use with the command-line interface.

DRC (DYNAMIC RANGE COMPRESSION)

DRC (dynamic range compression) reduces the dynamic range of audio. It can be useful if you have troubles understanding the audio with big dynamic changes. You can apply the audio filter within the -a option using the drc value.

HISTORY

HandBrake was initially developed in 2003. The command-line interface, HandBrakeCLI, has evolved alongside the GUI version to offer users scripting and automation capabilities. It has been widely adopted by media enthusiasts and professionals for its robustness and extensive feature set.

SEE ALSO

ffmpeg(1)

Copied to clipboard