[gst-devel] Simple TS to MKV converter

Dirk Meyer dischi at freevo.org
Tue Feb 6 16:08:03 CET 2007


Hi,

I'm trying to understand gstreamer and so I tried to write a small
python script that reads from a file, demuxes the transport stream (it
is a dvb recording) and saves the file as matroska file.

But, it does not work. I have no idea why, but the dest file is not
written. Maybe I'm making a fundamental design error. I read about
queues and set_active calls on the mailing list, but I have no idea
where to add this calls.


import sys

import pygst
pygst.require('0.10')
import gst
import gobject

def new_pad(demuxer, pad):
    pad.link(matroska.get_compatible_pad(pad))

def bus_event(bus, message):
    t = message.type
    if t == gst.MESSAGE_EOS:
        sys.exit(0)
    elif t == gst.MESSAGE_ERROR:
        err, debug = message.parse_error()
        print "Error: %s" % err, debug
        sys.exit(0)
    print message
    return True

pipeline = gst.Pipeline()
pipeline.get_bus().add_watch(bus_event)

source = gst.element_factory_make("filesrc")
source.set_property('location', '/home/dmeyer/zdf.ts')
mpegts = gst.element_factory_make('ffdemux_mpegts')

mpegts.connect("pad-added", new_pad)

matroska = gst.element_factory_make("matroskamux")
sink = gst.element_factory_make("filesink")
sink.set_property('location', '/home/dmeyer/zdf.mkv')

pipeline.add(source, mpegts, matroska, sink)

source.link(mpegts)
matroska.link(sink)

pipeline.set_state(gst.STATE_PLAYING)

gobject.MainLoop().run()



Regards,


Dischi

-- 
A tree never hits an automobile except in self-defence.




More information about the gstreamer-devel mailing list