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" ...