Menu

Custom programs

Krzysztof Kamil Jacewicz

Custom programs

The front4ffmpeg allows you to define your custom video processing program. You can defne a custom command line to be fed into the ffmpeg, and it can contain variables. Then you can also define visual controls to appear on the application's form to let you to interactively set your custom program's variables via GUI elements.

The config file on linux is located at: ~/.config/front4ffmpeg.conf

Consider this sample program:

<Program:Video scaling>
#definig program's command line:
command=$ffmpeg -i $IN -vf scale=-1:$videoh -c:v libx264 -crf 18 -preset veryslow -c:a copy $OUT
#Setting controls:
#"!" means that it's required setting, otherwise it's optional
!combobox:videoH=label=Target resolution:;FullHD (1080p)=1080;HD (720p)=720;Double VGA (DVGA 640p)=640;Wide VGA (WGA 480p)=480;HVGA (320p)=320; 240p=240;
!trackbar=label=Quality (lower number is higher quality):;min=0;max=25;step=1;position=18;
</Program>

you can include as many program definitions in the config file as you want, but every program definition has to be enclosed between tags: <Program:your_program_describtion> ... </Program> where your_program_describtion can be anything you want and it will be shown in the program selection drop-down list. Tags are not case sensitive.

inside a program definition block, you now define a set of key=value lines, and you can also include comments by prepending a line of text with a hashtag: #this is a comment.

A valid program must at least contain a key command= that will define a command line to be executed. From our example the command value is:
$ffmpeg -i $IN -vf scale=-1:$videoh -c:v libx264 -crf 18 -preset veryslow -c:a copy $OUT

Words that are prepended with a dollar sign $ are variables (case insensitive). there are 3 special variables that you can use in the command line:
$ffmpeg - this will be replaced by a valid path to ffmpeg executable
$IN - this will be replaced with the path of the source file (Source).
* $OUT - this will be replaced with the path of the destination file (Save As).

the $ffmpeg is supposed to ensure that the path is platform independent, that it will be correct regardless if your system is Linux, Mac or Windows. But you can - if you so wish - define your command line with your own path. In fact, it could even be another binary, not ffmpeg at all. The front4ffmpeg however only recognize the output formatted by ffmpeg as valid, so if you are feeding any other binary into your custom command line, you have to keep that in mind. You can always use custom binary that produces compatible output.

Any other variable except these 3 special ones listed above, is a regular variable. The names are only defined by you, and as long as they are different from the names of special variables, they are valid.

They way you are supposed to use regular variables in the custom command line, is that for each one that you define, you should define a visual control named the same as that variable. Upon execution of your custom program, for each defined regular variable a control with the same name will be looked for, and it will provide a value for substitution. If a control cannot be found, an error will be shown.

Every visual control is also defined as a key=value line of text within a program block, where the key portion is in the format: ControlType:ControlId , and the value portion defines its properties in a format that is defined separately for each control type. The ControlId is what should match the variable id in your command line definition.

The type of control (key) can be prepended with an exclamation sign ("!") to indicate that a control is a required variable. Otherwise it is treated as an optional variable, and user may choose to skip it.
REMARK : this feature (optional/required) has not effect in the current version, and will be finalized in the future.

So now consider the sample program definition shown in the beginning of this page. You can see that is has a control for a trackbar, which has no Id. Let's make use of it. We will namassign it an Id: !trackbar:quality and will use it as a variable valueon the command line, where it was a constant value of 18 in the previous example. We then have a sligtly modified program definition, as shown below, which is version's 0.9 built-in default:

<Program:Video scaling>
#definig program's command line:
command=$ffmpeg -i $IN -vf scale=-1:$videoh -c:v libx264 -crf $quality -preset veryslow -c:a copy $OUT
#Setting controls:
#"!" means that it's required setting, otherwise it's optional
!combobox:videoH=label=Target resolution:;FullHD (1080p)=1080;HD (720p)=720;Double VGA (DVGA 640p)=640;Wide VGA (WGA 480p)=480;HVGA (320p)=320; 240p=240;
!trackbar:quality=label=Quality (lower number is higher quality):;min=0;max=25;step=1;position=18;
</Program>

Below is a list of supported visual control types, and their property definition format. The common feature is that properties are supplied in the format of key=value each ended with a semicolon sign ";".

combobox

since version: 0.91
A drop-down list aka ComboBox. It defines a label property, which if defined, will appear next to the combobox. Any other property should be in a format key=value where the key is what will appear as the visible text in the drop-down list, and value is what will be used as variable value if selected.

trackbar

since version: 0.91
A visual slider allowing to chose a numerical value within a defined range. Properties:
label - if defined, will appear above the trackbar
min - defines the low end of the numerical range
max - defines the high end of the numerical range
step - defines the smallest step of the trackbar
position - defines the default numerical value


Related

Tickets: #1
Wiki: Home