I started out with gstreamer. It looked promising. It even had a element called "Tee" which seemed like a good thing for splitting the source video. Alas, the documentation was lacking. Especially regarding "Tee".
It seems I am not the first person to run into this problem. This article made me decide to switch to MLT. Openshot seems like a pretty developed, live project. If this guy was willing to put this much work into an MLT based project, then I thought I would give it a try.
Unfortunately things did not go much better in MLT. First, I had trouble installing it (Ubuntu 11.10). I solved that problem by installing Openshot. I installed the python bindings using the Ubuntu Software Center.
Next I found the docs to be pretty cryptic - given that I wanted to work in python. Eventually I found the mlt-0.7.8.tar.gz file. In ./src/swig/python was some demo code that was enough to get me started.
Below is some code that will open a media file and play it. Just assign the full path FILE and run.
import mlt
import os.path
import time
import sys
FILE='/home/chuck/Desktop/test-mpeg.mpg'
if os.path.exists(FILE):
# Start the mlt system
mlt.Factory().init( )
# Establish a profile
profile = mlt.Profile( )
# Create the producer
p = mlt.Producer( profile, FILE )
# Create the consumer
c = mlt.Consumer( profile, "sdl" )
# Turn off the default rescaling
c.set( "rescale", "none" )
# Connect the producer to the consumer
c.connect( p )
# Start the consumer
c.start( )
# Wait until the user stops the consumer - ie closes the window
while c.is_stopped( ) == 0:
print 'look, we can do other stuff while the video runs'
time.sleep( 1 )
print 'The window was closed.'
else:
# Diagnostics
print "Unable to open ", FILE
Not sure how I am going to solve my original problem. But this is a start.
Thank you for posting the code.
ReplyDelete