Using do_transform_frame in GstVideo.VideoFilter (python)

dpw157 dinethw04 at gmail.com
Tue Mar 27 21:36:17 UTC 2018


sure ill do that

btw here is the full code with registration and ill make a bug report right
now. I assume i report it here https://bugzilla.gnome.org/



import sys
import gi

gi.require_version('Gst', '1.0')
gi.require_version('GstVideo', '1.0')

from gi.repository import GObject, Gst, GstVideo

Gst.init(sys.argv)
GObject.threads_init()
Gst.segtrap_set_enabled(False)


class GstTimestamp(GstVideo.VideoFilter):
  __gstmetadata__ = ('<longname>', '<classification>',
                     '<description>', '<author>')

  __gsttemplates__ = (Gst.PadTemplate.new("sink",
                                           Gst.PadDirection.SINK,
                                           Gst.PadPresence.ALWAYS,
                                           Gst.Caps.new_any()),
                      Gst.PadTemplate.new("src",
                                           Gst.PadDirection.SRC,
                                           Gst.PadPresence.ALWAYS,
                                           Gst.Caps.new_any()))

  def __init__(self):
    GstVideo.VideoFilter.__init__(self)

  def do_transform_frame(self,inframe,outframe):

    #this should give me that data for the frame
    data = inframe.buffer
    #data is None
    print data

    #dont know if im properly sending data back since 
    #i just get blank screen 
    return Gst.FlowReturn.OK


#used for registration
def plugin_init(plugin):
    Gst.Element.register(plugin, 'timestamper', 0,
                         GObject.type_register(GstTimestamp))
    return True

def init():
  version = Gst.version()
  Gst.Plugin.register_static(
      version[0], version[1], 'timestamper', 'Timestamper',
      plugin_init, '1.0', 'GPL', 'timestamper',
      'plugins-demo', 'demo')

init()


def connect(bus, name):
    def _connect(f):
        bus.connect(name, f)
        return f
    return _connect

def main():
  pipeline = Gst.parse_launch('videotestsrc ! timestamper ! ximagesink')

  bus = pipeline.get_bus()
  bus.add_signal_watch()
  #Gst.debug_set_active(True)
  #Gst.debug_set_default_threshold(4)

  @connect(bus, "message::error")
  def on_error(bus, message):
      pipeline.set_state(Gst.State.NULL)
      exit(message.parse_error())

  @connect(bus, "message::eos")
  def on_eos(bus, message):
      pipeline.set_state(Gst.State.NULL)
      exit(0)

  pipeline.set_state(Gst.State.PLAYING)
  loop = GObject.MainLoop()
  try:
      loop.run()
  except(KeyboardInterrupt):
      pass

  pipeline.set_state(Gst.State.NULL)

if __name__ == '__main__':
  main()





--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list