Skip to content

Allow extra HandBrakeCLI arguments via config - #14

Open
jakobwesthoff wants to merge 3 commits into
dmars8047:releasefrom
jakobwesthoff:feat/handbrake_extra_args
Open

jakobwesthoff wants to merge 3 commits into
dmars8047:releasefrom
jakobwesthoff:feat/handbrake_extra_args

Conversation

@jakobwesthoff

@jakobwesthoff jakobwesthoff commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

With a custom preset configured, HandyMKV runs HandBrakeCLI with only --input, --output, --preset-import-file and --preset. Everything else has to come from the preset, and some things simply cannot.

A preset picks audio tracks by language only, as either "first" or "all". It cannot pick a track by index, and it applies one audio rule to every track it selects. So a disc with several tracks in the same language leaves you choosing between dropping tracks you want and keeping ones you don't.

I hit this on a Blu-ray with three English tracks: an LPCM mono original, a DTS-HD MA 5.1 remix, and the lossy DTS core of that same remix. "first" silently threw away the 5.1. "all" kept the redundant core and forced one bitrate onto both a 2-channel and a 6-channel track.

A new optional extra_handbrake_args setting:

"encoding_params": {
  "preset_file": "/path/to/preset.json",
  "handbrake_preset": "MyPreset",
  "extra_handbrake_args": [
    "-a", "1,2",
    "-E", "ca_aac,ca_aac",
    "-B", "160,640",
    "--mixdown", "stereo,5point1"
  ]
}

The arguments go after the preset, so HandBrakeCLI's own override rules apply: the preset still governs video, while these take over audio. The example keeps source tracks 1 and 2 at 160 and 640 kb/s and ignores the rest.

Arguments HandyMKV sets itself are rejected at config load rather than merged: --input, -i, --output, -o, --preset, --preset-import-file. Letting a config override those would quietly redirect an encode away from the staged input or the configured output directory.

The wizard does not prompt for the setting, since promptForStringSlice splits on commas and values like -a 1,2 contain them. It has to be added to config.json by hand.

Track indexes refer to the ripped MKV, not the disc, and only hold while every title shares a stream layout. Noted in the README.

The argument list was assembled inline in encode(), immediately before the
exec.Cmd it feeds, which left no way to assert on it without running
HandBrakeCLI. Pulling it into a plain function makes the resulting arguments
testable.
A HandBrake preset can only select audio tracks by language and by "first" or
"all", and applies a single audio rule to every track it selects. Discs
carrying several tracks in the same language cannot be handled by a preset
alone.

The arguments are appended after the preset, relying on HandBrakeCLI applying
an imported preset first and letting later flags override it, so a preset can
still govern video while these take over track selection.

Arguments handymkv derives itself are rejected rather than merged. Accepting
them would let a config silently redirect an encode away from the staged input
or the configured output directory.

The setting is not offered by the configuration wizard, since promptForStringSlice
splits on commas and HandBrakeCLI values such as `-a 1,2` contain them.
The encode parameters were assembled field by field from the config, so a
setting could be read from `config.json`, printed by the `config` subcommand,
and still never reach HandBrakeCLI. `extra_handbrake_args` was dropped this way,
and so were `include_all_relevant_audio` and `include_all_relevant_subtitles`,
which the wizard has always prompted for but which never resulted in
`--all-audio` or `--all-subtitles` being passed.

The configured settings already are an `EncodingParams`, so they are now copied
wholesale and only the per-title fields are overwritten. A setting added to the
struct is carried without having to be listed in a second place.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant