Using do_transform_frame in GstVideo.VideoFilter (python)

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Using do_transform_frame in GstVideo.VideoFilter (python)

dpw157
Hey all,
I have a question about using the do_transform_frame function when creating
your own elements.

1. Why is my buffer none within the GstVideo.VideoFrame object. For instance
when i try
print inframe.buffer
(which from my understanding should return a object of type Gst.Buffer)
instead returns None.

2. Why is the video a black screen when i dont change anything within
do_transform_frame. Do i have to push the outbuffer within the function. If
so how do i do this, since the return for do_transform_frame is a
Gst.FlowReturn, which are usually just True or False.

Thanks for taking the time to read this and helping me out



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using do_transform_frame in GstVideo.VideoFilter (python)

Mathieu Duponchelle
Hello,

Implementing elements in python, while supported, is not very thoroughly
tested, and what you are describing is most likely a bug.

Can you share a minimal example reproducing your issue, or even better
file a bug and attach such an example?

On 03/26/2018 08:07 PM, dpw157 wrote:

> Hey all,
> I have a question about using the do_transform_frame function when creating
> your own elements.
>
> 1. Why is my buffer none within the GstVideo.VideoFrame object. For instance
> when i try
> print inframe.buffer
> (which from my understanding should return a object of type Gst.Buffer)
> instead returns None.
>
> 2. Why is the video a black screen when i dont change anything within
> do_transform_frame. Do i have to push the outbuffer within the function. If
> so how do i do this, since the return for do_transform_frame is a
> Gst.FlowReturn, which are usually just True or False.
>
> Thanks for taking the time to read this and helping me out
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using do_transform_frame in GstVideo.VideoFilter (python)

dpw157
hey,

so here is some minimal code that may explain my issue.

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
    print data
    return Gst.FlowReturn.OK



When i do this every time a frame a pushed data is None and i just get a
blank screen from ximagesink.
Thanks for the help and taking the time to look at this



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using do_transform_frame in GstVideo.VideoFilter (python)

Mathieu Duponchelle
Can you please file a bug with that code, ideally including the registration code
and various imports to make things easy to reproduce?

On 03/27/2018 11:22 PM, dpw157 wrote:

> hey,
>
> so here is some minimal code that may explain my issue.
>
> 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
>     print data
>     return Gst.FlowReturn.OK
>
>
>
> When i do this every time a frame a pushed data is None and i just get a
> blank screen from ximagesink.
> Thanks for the help and taking the time to look at this
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using do_transform_frame in GstVideo.VideoFilter (python)

dpw157
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/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using do_transform_frame in GstVideo.VideoFilter (python)

Mathieu Duponchelle
Perfect, yes you want to report this at https://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer,
and select the gst-python component.

On 03/27/2018 11:36 PM, dpw157 wrote:

> 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/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using do_transform_frame in GstVideo.VideoFilter (python)

dpw157
hey,

K i posted the bug report and will try to help solve it(with my limited
knowledge). If their is anything else u need from me to help solve this
issue let me know

thanks



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using do_transform_frame in GstVideo.VideoFilter (python)

dpw157
In reply to this post by Mathieu Duponchelle
Oh just in case anyone wants the bug link or something
Bug 794744 - Data is none in buffer from GstVideo.VideoFrame
https://bugzilla.gnome.org/show_bug.cgi?id=794744



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel