Note: This script is highly personalized. There would need to be substantial revisions made before someone other than I uses it.
This Python script takes a MythTV recording, converts it into a standalone video file and stores it in the MythTV video library. I use it to archive TV series recordings.
The script must be run on a system that has a properly configured MythTV frontend installed.
Before the script is run the user may want to edit the recording(s) they plan to transcode, to remove commercials, etc. This is done using the MythTV editing function to create a "cutlist".
The workflow implemented in this script goes like this:
- The script first displays a list of all available recordings and prompts the user to select one.
- The script collects episode metadata from the MythTV database and TheTVDB and displays it.
- The script offers the user some options:
- To change the season and episode numbers,
- To normalize the audio volume,
- To only transcode the video, leaving out the steps that would store it back into MythTV's video library,
- To crop the black frame from a WGVU-Life (local alternate PBS channel) recording,
- To crop the black frame and remove the on-screen logo from a WGVU Create-TV (local alternate PBS channel) recording,
- To remove the on-screen logo from a WGVU (local PBS channel) recording
- A target path and file name are set to match the directory structure I've established on my MythTV server, based on the recording's series name, season and episode number.
- The script starts the
mythtranscode
command with the--cleancut
option, sending the output to FIFO pipes. Simultaneously, the script starts theffmpeg
command, reading audio and video from those pipes and transcoding it into a MP4 video file.
This is the core of the script, the reason that I wrote it. This is the only way to do frame-level edits of MythTV recordings. All ofher methods only support making cuts at keyframes. - If the user chose to normalize the audio then
ffmpeg
processes the MP4 file a second time, copying the video stream and re-encoding the audio, this time with normalization. I found that including the normalization in the previous step slowed things down dramatically. - Finally the video file is moved to the target path in the MythTV video library and a database entry is created for it.