LinuxCommandLibrary

handbrake

Convert video files

SYNOPSIS

HandBrakeCLI [OPTIONS] -i <input_file> -o <output_file>

PARAMETERS

-i, --input <file>
    Specifies the input video file or source (e.g., a path to a file or a device like /dev/sr0 for DVD).

-o, --output <file>
    Sets the path and filename for the output video file.

-Z, --preset <string>
    Applies a built-in or user-defined preset that pre-configures many encoding settings.

-f, --format <string>
    Defines the output container format (e.g., mp4, mkv, webm).

-e, --encoder <string>
    Selects the video encoder to use (e.g., x264, x265, vp8, vp9).

-q, --quality <float>
    Sets the average video quality for Constant Rate Factor (CRF) encoding. Lower values generally mean higher quality.

--vb, --video-bitrate <int>
    Sets the average video bitrate in kilobits per second (kbps) for Average Bitrate (ABR) encoding.

-C, --crop <T:B:L:R>
    Crops the video frame by specifying pixels from Top, Bottom, Left, and Right edges.

-w, --width <int>
    Sets the desired output video width. Height is adjusted proportionally by default.

-h, --height <int>
    Sets the desired output video height. Width is adjusted proportionally by default.

-c, --chapters <string>
    Specifies which chapters of the input to encode (e.g., 1-5 or 1,3,5).

-a, --audio <string>
    Selects specific audio tracks and their encoding settings (e.g., codec, bitrate).

-s, --subtitle <string>
    Selects subtitle tracks to include and their rendering options.

-d, --deinterlace <string>
    Applies a deinterlace filter to remove interlacing artifacts (e.g., yadif).

--optimize
    Optimizes the MP4 output file for web streaming (moves metadata to the beginning).

-v, --verbose <int>
    Sets the logging verbosity level for more detailed output during encoding.

--help
    Displays the full help message for HandBrakeCLI and exits.

--version
    Displays the HandBrakeCLI version information and exits.

DESCRIPTION

HandBrakeCLI is the command-line interface for HandBrake, a powerful open-source video transcoder. It enables users to convert video from nearly any format, including DVD and Blu-ray sources, into a selection of modern, widely supported codecs like H.264, H.265, VP8, and VP9, along with various audio codecs. It's an indispensable tool for tasks such as ripping physical media to digital files, optimizing videos for web streaming, or ensuring compatibility across different devices. Beyond basic conversion, HandBrakeCLI offers advanced features including chapter selection, subtitle inclusion, audio track manipulation, and the application of video filters like deinterlacing and denoising. Its robust command-line nature makes it perfectly suited for scripting, batch processing, and integration into automated video workflows on Linux servers or workstations.

CAVEATS

HandBrakeCLI can be computationally intensive, requiring significant CPU resources, especially for high-resolution or high-quality encodes.
DRM-protected media (e.g., commercial Blu-rays/DVDs) often require additional, third-party libraries (like libdvdcss) for decryption, which are not bundled with HandBrake.
Incorrect or suboptimal encoding settings can lead to disproportionately large file sizes, reduced video quality, or extended encoding times. It is recommended to experiment with settings on small clips first.

PRESETS

HandBrakeCLI includes a wide array of built-in presets (e.g., Fast 1080p30, HQ 720p30 Surround) that streamline the encoding process by pre-configuring numerous complex options. Users also have the flexibility to create and save their own custom presets for specific needs or repeated tasks.

BATCH PROCESSING

The command-line interface is a key advantage of HandBrakeCLI for scripting and automating the conversion of multiple video files. This is commonly achieved by using shell scripts with constructs like for loops to efficiently process entire directories of video content, making it ideal for large media libraries.

HISTORY

HandBrake began its journey in 2003 as an open-source tool primarily designed for ripping DVDs to a G4 PowerBook. Over the years, it evolved significantly, growing into a versatile, cross-platform video transcoder available with both a graphical user interface (GUI) and a powerful command-line interface (CLI). Its development has been largely community-driven, continuously incorporating support for new video and audio codecs, container formats, and hardware acceleration capabilities. The HandBrakeCLI version has become a staple for server-side video processing, automated workflows, and large-scale batch conversions due to its efficiency and scriptability.

SEE ALSO

ffmpeg(1), mplayer(1), mpv(1), mediainfo(1)

Copied to clipboard