Track Sorter
This flow element will sort the audio and subtitles tracks given the parameters and update the order in FFmpeg Builder.
When FFmpeg Builder: Executor is run the tracks will be written in the order specified.
Deleted tracks are always sorted after non-deleted tracks. This is the very first sort done.
Type
The type of tracks that should be reordered
Set Default
When this is enabled, the first track (audio or subtitle) will be set as the default track of its type.
Even if the the tracks do not get re-ordered, the first track will be now marked as default.
Sorters
Sorter | Type | Subtitle | Audio |
---|---|---|---|
Bitrate | Numeric | ✅ | |
Channels | Numeric | ✅ | |
Codec | String | ✅ | ✅ |
Language | String | ✅ | ✅ |
Title | String | ✅ | ✅ |
The Reversed
variant of each sorter just reverses the order the sorter would usually sort the values in.
For example, Bitrate Reversed
with no sort value would sort the bitrates greatest to smallest.
No Value
If no value is entered for the sorter, then the sorting is based on the value
Numeric values (Bitrate, Channels) will be sorted by their respective values
Strings (Codec, Language) will be sorted alphabetically.
Value
If a sorter has a value set, then the sorting is done as matching vs not matching.
So if the track matches the sorter, it will be sorted before a track that does not match the sorter.
Regex Sorting
String values can be sorted via regular expressions.
For example Codec
^(ac3|dts)$
would sort any track whose codec is either ac3
or dts
before any other tracks.
As mentioned earlier, sorting is done via matching/not matching so this does not sort ac3
then dts
.
Math Operations
The following math operations can be used on Numeric values
Operation | Description | Example |
---|---|---|
< | Value is less than the preceding value | <100 |
> | Value is greater than the preceding value | >128kbps |
= | Value equals the preceding value | =10Mbps |
<= | Value is less or equal to the preceding value | <=5.1 |
>= | Value is greater than or equal to the preceding value | >=5.1 |
!= | Value equals the preceding value | !=0 |
Unit Replacements
You can use these unit replacements when working with numeric values.
These are all case insensitive.
Unit | Replacement |
---|---|
mbps | value * 1_000_000 |
kbps | value * 1_000 |
kb | value * 1_000 |
mb | value * 1_000_000 |
gb | value * 1_000_000_000 |
tb | value * 1_000_000_000_000 |
kib | value * 1_024 |
mib | value * 1_048_576 |
gib | value * 1_073_741_824 |
tib | value * 1_099_511_627_776 |
Languages
Languages are treated as a special case, and when sorting this field, it will look up the ISO 639-2 language code from the LanguageHelper
and sort based on that code.
So you can enter English
and it will match any track that equals en
or eng
. As all these will be looked up and become eng
.
There is a speical orig
replacement that can be used to match the original language.
This requires the OriginalLanguage
variable to be set earlier on in the flow to work.
Title
Titles are treated as a Contains
check, unless using a regular expression. So you can enter commentary
and that will match Directors Commentary
etc.
Use Title Reversed
with commentary
to move all commentary tracks to the end for easy removal.
Outputs
- Tracks have been reordered in
FFmpeg Builder
- Tracks have NOT been reordered
Examples
Field | Value | Description |
---|---|---|
Channels | >=5.1 | First sort the tracks so any that have channels greater or equal to 5.1 are first |
Language | orig | Next move order by original langauge |
Bitrate Reversed | No value set, so order the bitrate in descending order |
So this example could produce, if the original language was German
Channels | Language | Bitrate | Reason |
---|---|---|---|
5.1 | deu | 100000 | Greater than/equal 5.1 , is German |
7.1 | fre | 10000 | Greater than/equal 5.1 |
4.0 | ger | 100000 | is German |
2.0 | jpn | 10000000 | Highest bitrate of remaining tracks |
5.0 | eng | 100000 |