Skip to content

Custom Encoder Specifications

DepFA edited this page Jan 16, 2023 · 2 revisions

The folder customEnoderSpecs allows users to specify their own series of flags to be sent to ffmpeg at encode time.

The general structure of the file should contain headers for name, extension, multi-pass-encode and some collection of commandBlocks

{
	"name":"VP9 10bpp",
	"baseEncoder":"",
	"extension":"webm",
	"multi-pass-encode":true,
	"commandBlocks":[...]
}

The properties name, extension are combined to create the name of the encoder in the gui, in the format extension:name, for example this encoder will appear as webm:VP9 10bpp

The listing of command blocks defines an ordered list of blocks of commands that are appended to the ffmpeg command before it's run, they can either be a straight list of commands like :

...
"commandBlocks":[
    {"cmds":["-shortest", "-copyts", "-start_at_zero", "-c:v","libvpx-vp9"]}
]
...

Which will always append -shortest -copyts -start_at_zero -c:v libvpx-vp9.

Or conditional blocks like:

...
"commandBlocks":[
    {
     "conditions":[["passPhase","equals","1"]],
     "cmds":[],
     "altCmds":["-speed", "1"]	
    }
]
...

Which will check if the condition passphrase equals 1 is true, if it evaluates to true the list of commands inside the cmds list is appended to the ffmpeg command line, if it's false the list of commands inside the altCmds is used instead - in this case in pass 1 of a multi-pass encode nothing is added, but in pass 2 -speed 1 is appended.

The first value in a condition should be a property exposed by the WmG encoder api, currently these are:

  • audioChannels - one of Copy, Stereo, Mono, No audio
  • forceBestDeadline - if the force Best Deadline option is set in the encode run.
  • br - the currently calculated bitrate.
  • passPhase - the multi stage encoding pass number 1 or 2 for multi-stage or 0 for single stage encodes.
  • metadata_title - a cleaned version of the filename for use in metadata embedding.
  • encoderStageThreads - the number of threads set to use in the WmG options.
  • maximumSize, maximumSize - the minimimum and maximum file size requested as output in Mb.
  • sizeLimitMax, sizeLimitMin - the minimimum and maximum file size requested as output in bytes.
  • minimumPSNR - the minimum requested PSNR for the output file quality.

All of these can also be used as merge values inside the commands when wrapped inside {braces}, such as using the calculated bitrate based on requested filesize:

...
"commandBlocks":[
    {"cmds":["-b:v", "{br}"]}
]
...

The json files may also exponse values and picklists to the user on the merge tab's 'Advanced Encode Options' button, for picklists:

...
{"selection":{	
    "name":"quality",
    "label":"Deadline / Quality",
    "default":"good",    
    "options":[
        {"name":"Good","cmds":["-quality", "good"]},
        {"name":"Best","cmds":["-quality", "best"]},
        {"name":"Realtime","cmds":["-quality", "realtime"]}
    ]
}},
...

Would expose 3 options in a picklist on the merge advanced options modal, with the label Deadline / Quality outputting a different quality flag for whichever was selected, whereas for values:

...
{"selection":{	
    "name":"lag-in-frames",
    "label":"VP9 lag-in-frames",
    "default":"25",
    "type":"int",
    "cmds":["-lag-in-frames", "{value}"]
}},

Exposes a property called 'VP9 lag-in-frames' and will set either the default value of 25 or any user provided value to be the parameter for the -lag-in-frames parameter.

A tool for cutting, filtering and joining video clips, supports webm, mp4 and high quality gif outputs.

Clone this wiki locally