Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Untitled
Sunday, August 27th, 2006 at 3:05:52am MDT 

  1. import sys
  2. import gobject
  3.  
  4. import pygst
  5. pygst.require ("0.10")
  6. import gst
  7.  
  8. def bus_message_eos_cb (bus, message, loop):
  9.         loop.quit ()
  10.  
  11. def bus_message_tag_cb (bus, message, pad):
  12.         taglist = message.parse_tag ()
  13.         try:
  14.                 tag = taglist["cmml-clip"]
  15.                 buf = gst.Buffer (tag.props.description)
  16.                 buf.timestamp = tag.props.start_time
  17.                 buf.duration = tag.props.end_time - tag.props.start_time
  18.                 print pad.push (buf)
  19.         except KeyError:
  20.                 return
  21.  
  22. def main ():
  23.         loop = gobject.MainLoop ()
  24.        
  25.         # setup playbin
  26.         playbin = gst.element_factory_make ("playbin")
  27.        
  28.         # create the video sink bin
  29.  
  30.         # create a pad and connect it to textoverlay
  31.         videosink = gst.Bin ()
  32.         textoverlay = gst.element_factory_make ("textoverlay")
  33.  
  34.         # create xvimagesink
  35.         xvimagesink = gst.element_factory_make ("xvimagesink")
  36.         videosink.add (textoverlay, xvimagesink)
  37.  
  38.         # create a srcpad to push data to textoverlay
  39.         pad = gst.Pad ("mysrc", gst.PAD_SRC)
  40.         pad.set_caps (gst.Caps ("text/plain"))
  41.         pad.link (textoverlay.get_pad ("text_sink"))
  42.  
  43.         textoverlay.link (xvimagesink)
  44.         videosink.add_pad (gst.GhostPad ("sink",
  45.                 textoverlay.get_pad ("video_sink")))
  46.  
  47.         playbin.set_property ("video-sink", videosink)
  48.         playbin.set_property ("uri", sys.argv[1])
  49.        
  50.         pipeline = gst.Pipeline ()
  51.         bus = gst.Bus ()
  52.         pipeline.set_bus (bus)
  53.         bus.add_signal_watch ()
  54.         bus.connect ("message::eos", bus_message_eos_cb, loop)
  55.         bus.connect ("message::tag", bus_message_tag_cb, pad)
  56.  
  57.         pipeline.add (playbin)
  58.         pipeline.set_state (gst.STATE_PLAYING)
  59.         loop.run ()
  60.         pipeline.set_state (gst.STATE_NULL)
  61.  
  62. if __name__ == '__main__':
  63.         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.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



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.

fantasy-obligation