This script accepts a transport stream as an argument [FILE] and does the following:
- Copies the original ts to a subdirectory within the system tmpdir
- Runs
comskip
to find commercial boundaries*. If found, it- Deletes them using
comcut
- Generates chapter boundaries at commercial breaks
- Deletes them using
- Extracts closed captions as subtitles
- Remuxes to mp4 to add chapter markers
- Transcodes to mkv to compress and add subtitles
- Cleans up after itself
- Deletes original ts
- Deletes temporary files
- Moves mkv to source directory (presumably .grab/)
It does all of this while respecting quiet hours and ensuring only one file is being processed at a time. It also produces detailed logs on its own and adds begin/end lines to the PMS logs.
comskip
: https://github.com/erikkaashoek/Comskipcomcut
: https://github.com/BrettSheleski/comchapccextractor
: https://github.com/CCExtractor/ccextractorffmpeg
: https://ffmpeg.org/HandbrakeCLI
: https://handbrake.fr/downloads.php
You can likely get some or all of these programs from your package manager.
As of Plex Media Server v1.19.3, the postprocessing script must be called from the Scripts directory inside the application data directory. For easy setup, use the quick start.
$ plex-dvr [options] [FILE]
option | type | description |
---|---|---|
--debug , -d |
Include stdout and stderr from all tools in logs (overrides verbose flag) |
|
--encoder , -e |
string | Video encoder string to pass to Handbrake. Run HandbrakeCLI --help to see available encoders. |
--help , -h |
show CLI help | |
--quiet-time , -q |
string | Quiet time, in the format of NN-NN where NN is an hour on the 24-hour clock (0 being midnight, 23 being 11pm). Default value 03-12 |
--verbose , -v |
Verbose logging to the console. | |
--encoder-preset |
string | Video encoder preset to pass to Handbrake. Run HandbrakeCLI --encoder-preset-list <string encoder> to see available presets. |
--ignore-quiet-time |
Process file immediately without checking against quiet time hours. | |
--[no-]keep-original |
Prevent original .ts file produced by Plex's DVR from being deleted. Default is false, prepend with --no- to flip. |
|
--[no-]keep-temp |
Prevent temporary working directory from being deleted. Default is false, prepend with --no- to flip. |
|
--sample-config |
Print default config values & config directory location and exit. |
plex-dvr /path/to/video
plex-dvr -q 22-06 -e vt_h264 /path/to/video