If you are working on the same machine and account as the GUI instance where you created the preset you can just select it with -z:
HandBrakeCLI -Z MyPreset -i inputfile.mpg -o outputfile.mp4
If you're trying to do it on another computer to where you set up the preset you will first need to export it from the GUI (in the presets menu) as a .plist file. Then you can import it (you need to do it every time, it doesn't save it) when you do the encode:
HandBrakeCLI --preset-import-file /path/to/preset.plist -Z "my preset" -i inputfile.mpg -o outputfile.mp4
It uses PresetName. The file name is only used for the purpose of opening the file, then it is forgotten and ignored.
If PresetName == "My Custom Preset"
and file is "somepreset.json"
, the correct command line to use that preset is:
HandBrakeCLI --preset-import-file somepreset.json -Z "My Custom Preset" ...
at least with OSX 20160707 nightly this doesnt behave quite as advertised - -Z is only for built-in presets. and the import options (--preset-import-file and --preset-import-gui) dont successfully work with an exported preset (.json) from the gui. and instead of failing, they default to x264/rf22.... – keen – 2016-07-12T02:53:22.120
HandBrakeCLI-20160707231111-0fc54d0 --preset-import-file ~/Library/Application\ Support/HandBrake/UserPresets.json -Z 'MY-CUSTOM-PRESET' -i input.mkv -o output.mkv however seems to be working - consuming the userpresets file from the gui, and specifying the specific preset in that. – keen – 2016-07-12T02:54:39.853
HandBrakeCLI-20160707231111-0fc54d0 --preset-import-file my-custom-preset-export.json -Z 'MY-CUSTOM-PRESET' -i input.mkv -o output.mkv - also works. note that I specified the file I exported the preset too AND the name of the preset. – keen – 2016-07-12T02:56:51.447