Filename templates

Filename templates

Tremendum Transcoder allows very flexible filename templates. These define how the resulting filename from processing a profile will be.

The filename template can optionally include variables that are replaced at run time with their calculated value.

%sourcename%
Contains the source filename without extension. ie. “video” from “video.mpg

%sourceext%
Contains the source extension only. ie. “mpg” from “video.mpg

%format%
Contains the profile identifier. ie. “webm_360” for the default WebM 360p video profile.

%ext%
This variable is mandatory, and contains the extension of the target filename as defined in the profile.

%width%
Contains the width as specified in the profile width setting.

%height%
Contains the height as specified in the profile height setting.

%outputwidth%
Contains the computed output width. The value is affected depending on the resize mode (crop, proportional, etc).

%outputheight%
Contains the computed output height. The value is affected depending on the resize mode.

%sourcewidth%
Contains the width from the source file.

%sourceheight%
Contains the height from the source file.

Filename templates also allow regular expressions to match against the source video filename and allows us to use the captures from the matches in the filename template. To make use of these variables, you need to set a "filename_regex" or "default_filename_regex" accordingly.

Please check the section that describes filename_regex for more info.

%rx1%
Contains the value of the first capture.

%rx2%
Contains the value of the second capture.

%rxN%
Contains the value of "N" (where N is a number) capture.

Variables that do not correspond to any capture are just removed from the filename template.

We also have a powerful feature that allows us to deal with the situation when no matches occur. In that case we can default the values of those non matched variables to a redefined static value, or one of the previous variable names. Pay attention to the special format and separator characters and notice how they differ: "% # %" and "% = %".

%rxN#VARIABLE%
This means replace with the capture "N" (where N is a number), and if we don’t match that capture, then use the "VARIABLE" value instead. ie: %rx1#sourcename%

%rxN=something%
This means replace with the capture "N" (where N is a number), and if we don’t match that capture, then use the literal text "something" instead. Notice the difference with the previous format, as the separator used is "=". ie. %rx1=some_text%

 

Filename Regex

The filename regex define the regular expression that is used to match against the source filename without extension (just the filename without the full path and without extension). These regular expressions are used to capture parts of text from the source filename and use it in the filename templates, allowing us to achieve very complex file naming schemes.

For example, let’s assume we want to create filenames that comply with the naming convention for a CMS that uses: video_title-format_short-number.ext

To make sure we preserve the naming convention from source files that are already in this CMS friendly format, and at the same time make sure we create a complying name from those source files that do not follow the convention, we would use the following combination:

default_filename_regex=(.+)?-(.+)?-(\d+)$
default_filename_template=%rx1#sourcename%-%format%-%rx3=1%.%ext%

To better illustrate the way this works, we will use 2 example source files:
encode/funny_monkey-movhd-3.mov
encode/surf_contest.mov

When processing those files with our settings and a profile called for example "mobile", the resulting filenames will be these:
done/funny_monkey-mobile-3.mp4
done/surf_contest-mobile-1.mp4

 

default_filename_template

Type: Optional
Default: %sourcename%-%format%.%ext%
Accepts: Filename template with special variables
Example: default_filename_template = %sourcename%-%format%.%ext%
Description: Sets the default filename template to use for profiles that do not define a specific one.

 

default_filename_regex

Type: Optional
Default: (empty)
Accepts: Regular expression without modifiers
Example: default_filename_regex = episode-(\d+)$
Description: Sets the Perl Compatible Regular Expression to capture groups of text to use in filename templates.

 

source_filename_template

Type: Optional
Default: (empty)
Accepts: Filename template with special variables
Example: source_filename_template = episode-(\d+)$
Description: Use the following filename template when copying / moving source media file to set a new filename. Note that only the following variables are available: %sourcename%, %ext%, %sourcewidth%, %sourceheight%, %rxN%, %rxN#VARIABLE%, $rxN=something%.

 

source_filename_regex

Type: Optional
Default: (empty)
Accepts: Regular expression without modifiers
Example: source_filename_regex = episode-(\d+)$
Description: Defines the regex to use in combination with source_filename_template.