-
Notifications
You must be signed in to change notification settings - Fork 1
MKV Tag Generator
Using the parameter -GenerateMKVTagFile (or its alias, -CreateTagFile) you can automatically pull, process, and mux custom XML tag files into your encoded output file. This only works for files in the Matroska format (duh), but it's a cool way to add interesting metadata to your container (it's also useful for media agents like Plex and Emby). The metadata is pulled from the TMDB API and requires a valid TMDB API key to work (it's free, you just need to sign up). Currently, there is very little support for TV shows (sorry).
The script called from the parameter will automatically attempt to detect the film's title and year based on the input path (if that data is present) using regular expressions, so giving your encode a clean output title is recommended. Sometimes, the wrong data is pulled and you will need to specify a title and year via parameters; this is especially true for films with multiple releases (Like Dune, for example) and foreign films.
The MKVToolnix suite, which can be downloaded here or from pretty much any package manager in existence. Specifically, the command line tools mkvmerge and mkvpropedit are used.
The parameter accepts a hashtable argument which is then splatted to the script MatroskaTagGenerator.ps1 in the scripts top-level directory. The script can accept the following parameters, either contained within the hashtable or run as a standalone script:
| Parameter | Mandatory | Description |
|---|---|---|
| Path | True | Path to the encoded output file - this is already covered by the -OutputPath parameter |
| APIKey | True | TMDB API Key |
| Title | False | Specify an optional clean title to use for search |
| Year | False | Specify the release year (sometimes required for multiple release films) |
| Properties | False | Pull additional metadata properties from the API by name (not guaranteed to work) |
| SkipProperties | False | Default properties to skip, like Cast, Directors, Writers, & IMDB ID (this can be customized) |
| NoMux | False | Creates the XML file, but does not multiplex it into the output file automatically |
| AllowClobber | False | Switch to enable overwriting of an existing XML files |
Only the -APIKey parameter is required as the other mandatory parameter -Path is already covered (unless you run the script on its own), but you can include them all if you want. Example:
PS > ./FFEncoder.ps1 ~/Movies/Ex_Machina_remux.mkv -CRF 18 `
>> -GenerateMKVTagFile @{APIKey='9862555x293fab2551aaffej22n93bb1'; SkipProperties=@('Writers','Directors'); NoMux=$true} `
>> -o '/Users/patrickenfuego/Movies/Ex Machina 2014.mkv'Notice the use of a clean title and year in the output filename - this is recommended but not required.
NOTE: The make changes, edit the script located at
FFEncoder/scripts/MatroskaTagGenerator.ps1in the project directory structure
You can set your own defaults for most of the parameters, depending on how you want to use it. You can also make APIKey non-mandatory and give it a default value so you don't have to pass it each time you run FFEncoder (this is what I do). To do this, change lines 88-90:
# Change this
[Parameter(Mandatory = $True, Position = 1)]
[Alias('Key')]
[string]$APIKey,
# To this
[Parameter(Mandatory = $false, Position = 1)]
[Alias('Key')]
[string]$APIKey = '9862555x293fab2551aaffej22n93bb1', # Whatever your API key isBy default, the script pulls the following metadata:
- TMDB ID
- IMDb ID
- Writers
- Directors
- Cast
If you want to exclude any of them, set a default value for -SkipProperties on lines 103-106:
[Parameter(Mandatory = $false)]
[Alias('Skip')]
[ValidateSet('Writers', 'Directors', 'Cast', 'IMDbID', 'TMDbID')]
[string[]]$SkipProperties = @('Writers', 'Directors', 'Cast'), # Edit the strings inside @() to exclude whatever properties you don't wantSimilarly, if you want to include specific metadata properties each time the script is called, set the -Properties parameter on line 101 in the same fashion. Note that the script doesn't check your input, so you must request valid metadata fields for this to work.
For more info:
PS > Get-Help .\scripts\MatroskaTagGenerator.ps1 -Full