Set a custom preset for HandbrakeCLI?

I'm at a very long task at converting 800+ small files to mp4, and I'm using Handbrake at the moment. Its fast, but since there are many files, it takes a lot of time. I created a automator workflow for HandbrakeCLI so I can batch convert files in any folder. This works great, but I need it to work with a custom preset I have on the Handbrake GUI. Can I import the preset to CLI somehow? I'm not a Lunix or terminal wiz.


Solution 1:

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

Solution 2:

I found out how to create and use an exported JSON.

I used the GUI to create the JSON, then used the following command to reference it from the command line:

HandBrakeCLI -v --preset-import-file 20RF.json -i input.ts file name -o output.mp4

I had created some that did not work.. and for some reason one that did, after editing and renaming it did not work. When I followed the following process it did.

  1. Create presets wanted in GUI and save as new preset given your name of choice.

  2. Presets - set Default (this sets your new preset as the default... when I don't do this it does not work)

  3. Presets - Export (name your new .json file.. was 20RF.json in my above example.)

The HandBrakeCLI will open and use the setting in the json file when created this way. I am using HandBrake 1.1.0 (x86_64) with an i5 8400 and Ubuntu mate 18.04

This is one of the threads which pointed me in the right direction to find out what worked on my system so wanted to share back.