py2avi

I watch a vari­ety of video con­tent on my TV using an orig­i­nal XBox and XBMC. Some of the pro­duc­ers of that con­tent have been switch­ing to higher qual­ity encod­ings using the Matroska con­tainer for­mat1 (e.g. MKV files). These fre­quently do not play well on my XBMC, so I transcode them into AVI files (XVid+MP3). I googled how to do this and found a handy bash script to do this2. The only down­side to that batch script was it did not extract the sub­ti­tles from MKV with “soft-subs“3. And being the lazy, for­get­ful git that I am; I usu­ally would only remem­ber as I went to play­back the video file. Plainly, this was unacceptable.

So I decided to write a python-script to auto­mat­i­cally: transcode the MKV file, extract the “soft-subs” and extract any attach­ments (usu­ally true-type font files). From this was py2avi born.

1 For more infor­ma­tion on con­tainer for­mats and video encod­ing, see A gen­tle intro­duc­tion to video encod­ing.

2I’ve since lost the link where I orig­i­nally found that bash script.

3“Soft-subs” are sub­ti­tles applied at play­back time from a sub­ti­tle datafile, either mixed directly into the video file (.mkv, .ogm, etc), or in a sep­a­rate file (.ssa, .srt, etc).

Require­ments

py2avi was devel­oped using Python 2.5 and requires: men­coder, mkv­tool­nix, avifile-xvid-plugin and lame to transcode and extract data from MKV files. py2avi was devel­oped and has been suc­cess­fully run under both Ubuntu 8.04.1 LTS (hardy) and Ubuntu 8.10 (intre­pid). py2avi may work else­where, but has not been tested to do so.

Doc­u­men­ta­tion

py2avi is designed to be a cli pro­gram. To run it, sim­ply type:

python py2avi.py video_file_to_be_transcoded.mkv

py2avi will then attempt to:

  • extract any “soft-subs” from video_file_to_be_transcoded.mkv and will write them to video_file_to_be_transcoded.ass
  • extract any other attach­ments included in the MKV file (usu­ally these will be true-type font files)
  • transcode the MKV to an AVI (XVid+MP3)

ChangeLog

  • 0.1.0: Ini­tial Release

To Do

  • Add abil­ity to over­ride options passed to men­coder for advanced users
  • Add abil­ity to transcode addi­tional file-types besides MKV.

License

py2avi is released under the GPL 2.0.

Down­load

Download py2avi v0.1.0