How-to use defaultSettings.py to set a custom x264 encoding profile

Started by butterw, May 13, 2021, 09:04:01 AM

Previous topic - Next topic

butterw

#How to set a custom x264 encoding profile and load it by default.

1) Save your custom x264 configuration to a a profile (ex: bProfile.json)
Example, if encoding time isn't a concern: Uncheck use Advanced Configuration, Preset: slower, Profile: high, crf slider: 23)
the file is created in settings\pluginSettings\x264\3\
you can now manually load the profile in the x264 configuration

2) To be able to load the profile via script it needs to be copied to settings\pluginSettings\x264\1\
ok = adm.videoCodecSetProfile("x264", "bProfile")
if not ok: raise("x264 Profile not found!")
This is much more compact than having to paste in the full x264 encoder configuration.

3) Once codec settings have been set, they are kept for the duration of the session. You can change to Copy and  switch back to x264 settings.
The configuration option "Revert to saved settings on video load" must be unchecked for this.

4) When you open Avidemux for the first time, Avidemux reverts to its default settings.
You can save the settings\defaultSettings.py file will be loaded when Avidemux starts with the menu command Edit>Save current Settings as default.

5) Finer customization is possible by manually editing defaultSettings.py.
ex: set Copy Mode, but also load your x264 encoding Profile.

adm = Avidemux(); gui = Gui()
profile = "bProfile"
ok = adm.videoCodecSetProfile("x264", profile)
if not ok: gui.displayError("settings/defaultSettings.py", "couldn't load x264 profile "+ profile + ".json")
adm.videoCodec("Copy")
adm.setContainer("MP4", "muxerType=0", "optimize=1", "forceAspectRatio=False", "aspectRatio=1", "displayWidth=1280", "rotation=0", "clockfreq=0")

6) keep a backup copy of your custom settings: .json x264 profile, defaultSettings.py and config3