- Untitled
- Sunday, August 27th, 2006 at 3:05:52am MDT
- import sys
- import gobject
- import pygst
- pygst.require ("0.10")
- import gst
- def 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:
- return
- def 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 ()
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.