gstreamer/examples/gst/filesrc.py
Johan Dahlin a37dede09c examples/gstreamer/filesrc.py,player.py: New examples
Original commit message from CVS:
* examples/gstreamer/filesrc.py,player.py: New examples

* gstreamer/gstreamer.override: Add a dict like interface to GstTagList

* gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override

* gstreamer/gst-types.defs: Don't use
gst_buffer_free/gst_data_free, use gst_data_unref instead.

* gstreamer/gst-types.c (PyGstData_to_value): Don't send address here.

* gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the
address to stuff, since we really want to avoid segfaults :)

* gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7

* gstreamer/0.7.[c,defs,h,override]: Remove, merge with
gstreamer.*

* gstreamer/Makefile.am: Clean up, remove versioning support.
2004-02-27 18:01:52 +00:00

54 lines
1.3 KiB
Python
Executable file

import sys
import gobject
import gst
class FileSource(gst.Element):
blocksize = 4096
fd = None
def __init__(self, name):
self.__gobject_init__()
self.set_name(name)
self.srcpad = gst.Pad('src', gst.PAD_SRC)
self.srcpad.set_get_function(self.srcpad_get)
self.add_pad(self.srcpad)
def set_property(self, name, value):
if name == 'location':
self.fd = open(value, 'r')
def srcpad_get(self, pad):
data = self.fd.read(self.blocksize)
if data:
return gst.Buffer(data)
else:
self.set_eos()
return gst.Event(gst.EVENT_EOS)
gobject.type_register(FileSource)
def main(args):
if len(args) != 3:
print 'Usage: %s input output' % (args[0])
return -1
bin = gst.Pipeline('pipeline')
filesrc = FileSource('filesource')
#filesrc = gst.Element('filesrc', 'src')
filesrc.set_property('location', args[1])
filesink = gst.Element('filesink', 'sink')
filesink.set_property('location', args[2])
bin.add_many(filesrc, filesink)
gst.element_link_many(filesrc, filesink)
bin.set_state(gst.STATE_PLAYING);
while bin.iterate():
pass
bin.set_state(gst.STATE_NULL)
if __name__ == '__main__':
sys.exit(main(sys.argv))