Skip to content

lucas-j/transcode.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 

Repository files navigation

This program uses a MythTV database or WTV recording to transcode
recorded TV programs to MPEG-4 or Matroska video using the H.264/AAC
or VP8/Vorbis/FLAC codecs, cutting the video at certain commercial points
detected by either MythTV or by Comskip. The resulting video file comes
complete with SRT subtitles extracted from the embedded VBI closed-caption
data. and iTunes-compatible metadata about the episode, if it can be found.
Optionally, existing MPEG-4 or Matroska video with proper filenames can be
tagged with metadata obtained from open movie / TV databases.

In short, this program calls a bunch of programs to convert a file like
1041_20100523000000.mpg or Program Name_ABC_2010_05_23_00_00_00.wtv into a
file like /srv/video/Program Name/Program Name - Episode Name.mp4,
including captions, file tags, chapters, and with commercials removed.

This program has been tested on Windows, Linux and FreeBSD, and can optionally
transcode from remote sources - e.g., mythbackend / MySQL running on a
different computer, or WTV source files from a remote SMB share / HomeGroup.

Requirements:
- FFmpeg (http://ffmpeg.org)
- Java (http://www.java.com)
- Project-X (http://project-x.sourceforge.net)
- remuxTool.jar (http://babgvant.com/downloads/dburckh/remuxTool.jar)
- Python 2.7 (http://www.python.org)
  - lxml (http://lxml.de)
  - mysql-python (http://sourceforge.net/projects/mysql-python)
  - Tmdb3 (https://github.com/wagnerrp/pytmdb3)
  - the MythTV Python bindings (if MythTV is not installed already)

For MPEG-4 / H.264:
- MP4Box (http://gpac.sourceforge.net)
- neroAacEnc (http://www.nero.com/enu/technologies-aac-codec.html) (optional)
- FFmpeg must be compiled with --enable-libx264
- if using faac for audio, FFmpeg must be compiled with --enable-libfaac

For Matroska / VP8:
- MKVToolNix (http://www.bunkus.org/videotools/mkvtoolnix/)
- FFmpeg must be compiled with --enable-libvpx and --enable-libvorbis

Optional dependencies:
- ccextractor (http://ccextractor.sourceforge.net)
- AtomicParsley (https://bitbucket.org/wez/atomicparsley)

Most of these packages can usually be found in various Linux software
repositories or as pre-compiled Windows binaries.

Setup:
- Make sure the above dependencies are installed on your system. Add each
  binary location to your PATH variable if necessary.
- Edit the settings in transcode.conf to your preference. At a minimum,
  specify paths to Project-X and remuxTool, specify a directory to output
  transcoded video, and enter your MythTV host IP (if using MythTV).
- If on Linux, optionally install transcode.py to /usr/local/bin and
  copy transcode.conf to ~/.transcode - otherwise, run the program from
  within its directory.

Usage:
  transcode.py %CHANID% %STARTTIME%
  transcode.py /path/to/file.wtv
  transcode.py /path/to/file.m4v
See transcode.py --help for more details

Notes on format string:
Each of the below tags are replaced with the respective metadata obtained
from MythTV, the WTV file, or Tvdb, if it can be found. Path separators
(slashes) indicate that new directories are to be created if necessary.
  %T - title (name of the show)
  %S - subtilte (name of the episode)
  %R - description (short plot synopsis)
  %C - category (genre of the show)
  %n - episode production code (or %s%e if unavailable)
  %s - season number
  %E - episode number (as reported by Tvdb)
  %e - episode number, padded with zeroes if necessary
  %r - content rating (e.g., TV-G)
  %oy - year of original air date (two digits)
  %oY - year of original air date (full four digits)
  %om - month of original air date (two digits)
  %od - day of original air date (two digits)
  
Special thanks to:
- #MythTV Freenode
- wagnerrp, the maintainer of the Python MythTV bindings
- Project-X team

Changelog:
1.4 - added TMDb support, deinterlace / auto-crop filter, direct tagging
1.3 - support for Matroska / VP8, fixed subtitle sync problems
1.2 - better accuracy for commercial clipping, easier configuration
1.1 - support for multiple audio streams, Comskip
1.0 - initial release

TODO:
- better error handling
- check for adequate disk space on temporary directory and destination
- generate thumbnail if necessary
- better genre interpretation for WTV files / TMDb movies
- allow users to manually enter in metadata if none can be found
- interactive menu option to resolve ambiguous metadata
- split transcode.py into several individual modules
- MythVideo integration
- better MythTV job integration

Long-term goals:
- support for boxed-set TV seasons on DVD
- metadata / chapter support for as many different players as possible,
  especially Windows Media Player
- easier installation: all required programs should be bundled
- Python 3.x compatibility
- a separate program for viewing / editing Comskip data

Known issues:
- subtitle font is sometimes too large on QuickTime / iTunes / iPods
- many Matroska players seem to have trouble displaying metadata properly
- AtomicParsley can crash on MPEG-4 files larger than 2 GB
- no Unicode support for AtomicParsley on Windows (Python bug)

About

Command-line MythTV / WTV transcoder

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages