All pastes #150771 Raw Edit

Untitled

public python v1 · immutable
#150771 ·published 2006-08-27 09:05 UTC
rendered paste body
import sysimport gobjectimport pygstpygst.require ("0.10")import gstdef bus_message_eos_cb (bus, message, loop):	loop.quit ()def bus_message_tag_cb (bus, message, pad):	taglist = message.parse_tag ()	try:		tag = taglist["cmml-clip"]		buf = gst.Buffer (tag.props.description)		buf.timestamp = tag.props.start_time		buf.duration = tag.props.end_time - tag.props.start_time		print pad.push (buf)	except KeyError:		returndef main ():	loop = gobject.MainLoop ()		# setup playbin	playbin = gst.element_factory_make ("playbin")		# create the video sink bin	# create a pad and connect it to textoverlay	videosink = gst.Bin ()	textoverlay = gst.element_factory_make ("textoverlay")	# create xvimagesink	xvimagesink = gst.element_factory_make ("xvimagesink")	videosink.add (textoverlay, xvimagesink)	# create a srcpad to push data to textoverlay	pad = gst.Pad ("mysrc", gst.PAD_SRC)	pad.set_caps (gst.Caps ("text/plain"))	pad.link (textoverlay.get_pad ("text_sink"))	textoverlay.link (xvimagesink)	videosink.add_pad (gst.GhostPad ("sink",		textoverlay.get_pad ("video_sink")))	playbin.set_property ("video-sink", videosink)	playbin.set_property ("uri", sys.argv[1])		pipeline = gst.Pipeline ()	bus = gst.Bus ()	pipeline.set_bus (bus)	bus.add_signal_watch ()	bus.connect ("message::eos", bus_message_eos_cb, loop)	bus.connect ("message::tag", bus_message_tag_cb, pad)	pipeline.add (playbin)	pipeline.set_state (gst.STATE_PLAYING)	loop.run ()	pipeline.set_state (gst.STATE_NULL)if __name__ == '__main__':	main ()