PyTranscode - FFMPEG management for python

PyTranscode is a set of classes that control and report from FFMPEG. They also make using FFMPEG from python very very simple.

Things you can do with PyTranscode:

  • Transcode videos from format a to b using presets stored in another file
  • Extract splash images from a video file (actually extracts a series of splash images at user-defined intervals)
  • Objectify video files – create a VideoObject form a file and it will provide you with all the details of the file from framerate to duration to formats used in both audio and video
  • Runner – run FFMPEG command and trap the output, reporting back percentage complete of any action

This software is being released under the GPL v3 because I think it should be out there and I think it’s important to get a handle on video in python as there just isn’t any up-to-date code out there that truly wraps FFMPEG’s functionality up (not in any modern way anyway).

There is an overarching strategy to this, PyTranscode will hopefully form a cornerstone of my next Django project – unnamed at the time of writing, that will essentially offer:

  • A storage engine for local or cloud-based storage
  • A queue manager for scaling, this again would have vairous back-ends for local queue management or something like Amazon Queue Service
  • A transcode server that can be run on multpile machines and be managed via an API OR be run in a mode to interact with the queue service
  • An API wrapper to control the transcode-server for common tasks

Anyone interested in contributing please contact me on Twitter @lonelycode or leave a message on the blog – I’ll be glad to get back to you.

The project is hosted on google code and can be found here

Sample usage:

from ffmpeg import *
from presets import *
from runner import *

def testrun():
infile = 'video.avi'
outfile = 'result.flv'
logfile = 'logthis.txt'

# Create the command line
cl = ffmpeg(infile, outfile, logfile, HQ_FLV_VIDEO, HQ_FLV_AUDIO).build_command_line()

# setup the command thread
run = FuncThread(runTranscode, cl, logfile)

# Set up the tracking thread
track = FuncThread(runTracker, logfile)

# Start run and tracker
run.start()
track.start()

testrun()

Enjoy!,

M