import gst
import gtk

class Player:
    def __init__(self):
        self.src = gst.element_factory_make('filesrc')
        self.dec = gst.element_factory_make('decodebin')
        self.csp = gst.element_factory_make('ffmpegcolorspace')
        self.scl = gst.element_factory_make('videoscale')
        self.sink = gst.element_factory_make('ximagesink')
        self.pipeline = gst.Pipeline()
        self.pipeline.add(self.src,self.dec,self.csp,self.scl,self.sink)
        
        self.src.link(self.dec)
        self.dec.connect('pad-added',self.__padAddedToDecodebin__)
        self.csp.link(self.scl)
        self.scl.link(self.sink)
        
        self.src.set_property('location','/tmp/myvideo.avi')
        
    def __padAddedToDecodebin__(self,element,pad):
        pad.link(self.csp.get_pad('sink'))
        
    def start(self):
        self.pipeline.set_state(gst.STATE_PLAYING)
        
myPlayer = Player()
myPlayer.start()

gtk.main() 