LinuxCommandLibrary

handbrake

Convert video files

SYNOPSIS

HandBrakeCLI [options] -i input -o output

PARAMETERS

-h, --help
    Show help and exit

--preset <name>
    Select preset (e.g., 'Fast 1080p30'; list with --preset-list)

-i, --input <path>
    Input file, directory, URL, DVD/Blu-ray device

-o, --output <path>
    Output file path (required)

-t, --title <index>
    Title index to encode (default: longest)

-c, --chapters <start-end>
    Chapter range (e.g., 1-5)

-f, --format <format>
    Container: mp4, mkv, webm (default: mp4)

-e, --encoder <encoder>
    Video encoder: x264, x265, vp9, nvenc_h264 (etc.)

-q, --quality <float>
    Constant quality (CRF, lower=better; 20-24 typical)

-b, --vb <bitrate>
    Average video bitrate (kbps)

--2pass
    Enable 2-pass encoding

--turbo-firstpass
    Faster first pass

-E, --audio <tracks>
    Audio track indices (e.g., 1,2)

--audio-lang <list>
    Preferred audio languages (e.g., eng,spa)

--all-audio
    Include all audio tracks

--sub <tracks>
    Subtitle track indices

--all-subs
    Include all subtitles

--native-language <eng>
    Default language for SRT subs

--srt-lang <list>
    Languages for SRT generation

--srt-file <path>
    Default SRT filename

--srt-burn <track>
    Burn subtitle into video

--crop <values>
    Crop dimensions (top,bottom,left,right)

--width <pixels>
    Output width

--height <pixels>
    Output height

--loose-crop
    Detect crop automatically

--no-loose-crop
    Disable auto crop

--optimize
    Web-optimized MP4

--ipod-touch
    iPod/iPhone compatibility

--filter <filter:strength>
    Filters: decomb, denoise, nlmeans, hqdn3d, nlmeans, scale, rotate

--decomb
    Deinterlace mode (default: on)

--detelecine
    Detelecine mode

--deinterlace=mode
    Deinterlace filter modes

--encoder-preset <preset>
    Encoder preset (ultrafast to placebo)

--encoder-profile <profile>, --encoder-level <level>
    H.264 profile/level

--encoder-tune <tune>
    Encoder tuning (film, animation)

--avcodec-options <key=value>
    Pass options to libavcodec

--markers
    Add chapter markers

--verbose=level
    Verbosity (0-2)

--debug
    Enable debug logging

--input-dir-scan
    Scan input directory

-Z, --preset-import <file>
    Import JSON preset

--preset-export <file>
    Export current as JSON

--preset-list
    List built-in presets

--help-gui
    GUI-specific help

--version
    Print version

DESCRIPTION

HandBrakeCLI (often invoked as HandBrakeCLI) is the command-line interface for HandBrake, a free, open-source tool for converting video from nearly any format to modern codecs like H.264, H.265, VP8, and VP9. It excels in batch processing, device presets (e.g., iPhone, Android), and high-quality encoding with features like 2-pass encoding, deinterlacing, denoising, cropping, scaling, and subtitles burn-in.

Supports input from files, DVDs, Blu-rays (requires libdvdcss for decryption), URLs, and directories for batch jobs. Outputs to MP4, MKV, WebM. Leverages FFmpeg for demuxing/decoding, with hardware acceleration via NVENC, Quick Sync, and VCE. Ideal for servers, automation, or headless Linux setups.

Presets simplify common tasks; advanced users tweak bitrate, CRF quality, filters, audio tracks, and chapters. Licensed under GPL, cross-platform, actively maintained.

CAVEATS

DVD/Blu-ray decryption requires separate libdvdcss install (legal in open-source contexts). Heavy CPU/GPU usage; test presets first. No real-time encoding by default. Outputs overwrite without warning. Large jobs need ample RAM/disk space.
Some encoders (e.g., NVENC) require NVIDIA drivers.

PRESETS

Use --preset-list to view (e.g., General, Web, Devices, HQ). Custom JSON presets via -Z file.json.

EXAMPLES

HandBrakeCLI -i input.mkv -o output.mp4 -q 22 --preset="Fast 1080p30"
HandBrakeCLI -i /dev/sr0 -o dvd.mp4 --preset="HQ 480p30 Surround" --main-feature
HandBrakeCLI -i *.mkv -o converted/%f.mp4 --preset="Very Fast 720p30"

BATCH MODE

Queue via directory input: -i /path/to/videos --preset="HQ 1080p30 Surround" -o /output/%shortfile%.mkv. Use scripts for complex workflows.

HISTORY

HandBrake project started in 2003 by Eric Petit as a Mac OS GUI for video encoding. CLI (HandBrakeCLI) added in 0.9.3 (2008). Linux support via FFmpeg integration since early versions. Now at v1.8+ (2024), with x265, AV1, hardware accel. Maintained by volunteers on GitHub.

SEE ALSO

ffmpeg(1), ffprobe(1), mkvmerge(1), mp4box(1)

Copied to clipboard