proxysink/src timing/lag/stutter issue.

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

proxysink/src timing/lag/stutter issue.

Chris Duncan
I may be implementing proxysink/src incorrectly but i am having issues. It seems as though proxysrc is either queuing up buffers or there is a timestamping issue. Any help would be greatly appreciated. 

#!/usr/bin/python3
import gi
gi.require_version(
'Gst', '1.0')
gi.require_version(
'GstRtspServer', '1.0')
from gi.repository import Gst, GstRtspServer, GObject

class RTSP_Factory(GstRtspServer.RTSPMediaFactory):
def __init__(self, pipeline, clock):
self.clock=clock
self.pipeline = pipeline
GstRtspServer.RTSPMediaFactory.
__init__(self)

def do_create_element(self, url):
self.pipeline.set_start_time(Gst.CLOCK_TIME_NONE)
return self.pipeline

def do_configure(self, media):
media.set_shared(
True)

Gst.init()
GObject.threads_init()
loop = GObject.MainLoop()
Gst.debug_set_active(
True)
Gst.debug_set_default_threshold(
4)


mainpipeline = Gst.parse_launch(
"nvcamerasrc "
"! video/x-raw(memory:NVMM), width=(int)2592, height=(int)1458, format=(string)I420, framerate=(fraction)30/1 "
"! omxh264enc bitrate=4000000 profile=2 control-rate=2 insert-sps-pps=true insert-aud=true insert-vui=true iframeinterval=20 "
"! video/x-h264, stream-format=byte-stream, profile=(string)main "
"! tee ! proxysink name=psink")

rtsppipeline = Gst.parse_launch(
"proxysrc name=psrc is-live=true ! queue name=rq max-size-buffers=3 ! h264parse ! rtph264pay name=pay0 pt=96 config-interval=1")


sysclock = Gst.SystemClock.obtain()

psink = mainpipeline.get_by_name(
"psink")
psrc = rtsppipeline.get_by_name(
"psrc")

psrc.set_property(
"proxysink", psink)

mainpipeline.use_clock(sysclock)
rtsppipeline.use_clock(sysclock)
mainpipeline.set_base_time(
0)
rtsppipeline.set_base_time(
0)
#mainpipeline.set_start_time(Gst.CLOCK_TIME_NONE)
rtsppipeline.set_start_time(Gst.CLOCK_TIME_NONE)

server = GstRtspServer.RTSPServer()
mounts = server.get_mount_points()
factory = RTSP_Factory(rtsppipeline, sysclock)

mounts.add_factory(
"/test", factory)
server.attach(
None)

mainpipeline.set_state(Gst.State.PLAYING)
loop.run()

Regards,
Chris



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

Re: proxysink/src timing/lag/stutter issue.

daniel-2
W dniu 2018-05-24 16:56, Chris Duncan napisał(a):

> I may be implementing proxysink/src incorrectly but i am having
> issues. It seems as though proxysrc is either queuing up buffers or
> there is a timestamping issue. Any help would be greatly appreciated.
>
> #!/usr/bin/python3
> import gi
> gi.require_version('Gst', '1.0')
> gi.require_version('GstRtspServer', '1.0')
> from gi.repository import Gst, GstRtspServer, GObject
>
> class RTSP_Factory(GstRtspServer.RTSPMediaFactory):
>     def __init__(self, pipeline, clock):
>         self.clock=clock
>         self.pipeline = pipeline
>         GstRtspServer.RTSPMediaFactory.__init__(self)
>
>     def do_create_element(self, url):
>         self.pipeline.set_start_time(Gst.CLOCK_TIME_NONE)
>         return self.pipeline
>
>     def do_configure(self, media):
>         media.set_shared(True)
>
> Gst.init()
> GObject.threads_init()
> loop = GObject.MainLoop()
> Gst.debug_set_active(True)
> Gst.debug_set_default_threshold(4)
>
> mainpipeline = Gst.parse_launch("nvcamerasrc "
>                                 "! video/x-raw(memory:NVMM),
> width=(int)2592, height=(int)1458, format=(string)I420,
> framerate=(fraction)30/1 "
>                                 "! omxh264enc bitrate=4000000
> profile=2 control-rate=2 insert-sps-pps=true insert-aud=true
> insert-vui=true iframeinterval=20 "
>                                 "! video/x-h264,
> stream-format=byte-stream, profile=(string)main "
>                                 "! tee ! proxysink name=psink")
>
> rtsppipeline = Gst.parse_launch("proxysrc name=psrc is-live=true !
> queue name=rq max-size-buffers=3 ! h264parse ! rtph264pay name=pay0
> pt=96 config-interval=1")
>
> sysclock = Gst.SystemClock.obtain()
>
> psink = mainpipeline.get_by_name("psink")
> psrc = rtsppipeline.get_by_name("psrc")
>
> psrc.set_property("proxysink", psink)
>
> mainpipeline.use_clock(sysclock)
> rtsppipeline.use_clock(sysclock)
> mainpipeline.set_base_time(0)
> rtsppipeline.set_base_time(0)
> #mainpipeline.set_start_time(Gst.CLOCK_TIME_NONE)
> rtsppipeline.set_start_time(Gst.CLOCK_TIME_NONE)
>
> server = GstRtspServer.RTSPServer()
> mounts = server.get_mount_points()
> factory = RTSP_Factory(rtsppipeline, sysclock)
>
> mounts.add_factory("/test", factory)
> server.attach(None)
>
> mainpipeline.set_state(Gst.State.PLAYING)
> loop.run()
>
> Regards,
> Chris
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

I asked similar question yesterday. Fortunately today after doing some
tests I have found why it does not work and how to fix it. When pipeline
goes to PLAYING state, it updates its base time to current time. To fix
this, you have to get base time from one pipeline and set it as base
time for second one. I do this just after setting state of 2nd one to
PLAYING.

You also should remove lines which change start time, this produces some
strange results.

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

Re: proxysink/src timing/lag/stutter issue.

Chris Duncan
I think this is entirely down to the "media-pipeline" created by rtspserver being out of sync. Looking into this now.

Regards,
Chris

On Thu, May 24, 2018 at 5:11 PM <[hidden email]> wrote:
W dniu 2018-05-24 16:56, Chris Duncan napisał(a):
> I may be implementing proxysink/src incorrectly but i am having
> issues. It seems as though proxysrc is either queuing up buffers or
> there is a timestamping issue. Any help would be greatly appreciated.
>
> #!/usr/bin/python3
> import gi
> gi.require_version('Gst', '1.0')
> gi.require_version('GstRtspServer', '1.0')
> from gi.repository import Gst, GstRtspServer, GObject
>
> class RTSP_Factory(GstRtspServer.RTSPMediaFactory):
>     def __init__(self, pipeline, clock):
>         self.clock=clock
>         self.pipeline = pipeline
>         GstRtspServer.RTSPMediaFactory.__init__(self)
>
>     def do_create_element(self, url):
>         self.pipeline.set_start_time(Gst.CLOCK_TIME_NONE)
>         return self.pipeline
>
>     def do_configure(self, media):
>         media.set_shared(True)
>
> Gst.init()
> GObject.threads_init()
> loop = GObject.MainLoop()
> Gst.debug_set_active(True)
> Gst.debug_set_default_threshold(4)
>
> mainpipeline = Gst.parse_launch("nvcamerasrc "
>                                 "! video/x-raw(memory:NVMM),
> width=(int)2592, height=(int)1458, format=(string)I420,
> framerate=(fraction)30/1 "
>                                 "! omxh264enc bitrate=4000000
> profile=2 control-rate=2 insert-sps-pps=true insert-aud=true
> insert-vui=true iframeinterval=20 "
>                                 "! video/x-h264,
> stream-format=byte-stream, profile=(string)main "
>                                 "! tee ! proxysink name=psink")
>
> rtsppipeline = Gst.parse_launch("proxysrc name=psrc is-live=true !
> queue name=rq max-size-buffers=3 ! h264parse ! rtph264pay name=pay0
> pt=96 config-interval=1")
>
> sysclock = Gst.SystemClock.obtain()
>
> psink = mainpipeline.get_by_name("psink")
> psrc = rtsppipeline.get_by_name("psrc")
>
> psrc.set_property("proxysink", psink)
>
> mainpipeline.use_clock(sysclock)
> rtsppipeline.use_clock(sysclock)
> mainpipeline.set_base_time(0)
> rtsppipeline.set_base_time(0)
> #mainpipeline.set_start_time(Gst.CLOCK_TIME_NONE)
> rtsppipeline.set_start_time(Gst.CLOCK_TIME_NONE)
>
> server = GstRtspServer.RTSPServer()
> mounts = server.get_mount_points()
> factory = RTSP_Factory(rtsppipeline, sysclock)
>
> mounts.add_factory("/test", factory)
> server.attach(None)
>
> mainpipeline.set_state(Gst.State.PLAYING)
> loop.run()
>
> Regards,
> Chris
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

I asked similar question yesterday. Fortunately today after doing some
tests I have found why it does not work and how to fix it. When pipeline
goes to PLAYING state, it updates its base time to current time. To fix
this, you have to get base time from one pipeline and set it as base
time for second one. I do this just after setting state of 2nd one to
PLAYING.

You also should remove lines which change start time, this produces some
strange results.

Regards,
Daniel
_______________________________________________
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: proxysink/src timing/lag/stutter issue.

Nirbheek Chauhan
Hi Daniel, Chris,

Have you seen this bug report about this problem? This specific comment has
instructions that should make it work:

https://bugzilla.gnome.org/show_bug.cgi?id=794893#c2

There are other issues related to the RTSP server that are not resolved
yet. Perhaps we should discuss details on the bug report?

Cheers,
Nirbheek
On Fri, May 25, 2018 at 12:57 PM Chris Duncan <[hidden email]>
wrote:

> I think this is entirely down to the "media-pipeline" created by
rtspserver being out of sync. Looking into this now.

> Regards,
> Chris

> On Thu, May 24, 2018 at 5:11 PM <[hidden email]> wrote:

>> W dniu 2018-05-24 16:56, Chris Duncan napisał(a):
>> > I may be implementing proxysink/src incorrectly but i am having
>> > issues. It seems as though proxysrc is either queuing up buffers or
>> > there is a timestamping issue. Any help would be greatly appreciated.
>> >
>> > #!/usr/bin/python3
>> > import gi
>> > gi.require_version('Gst', '1.0')
>> > gi.require_version('GstRtspServer', '1.0')
>> > from gi.repository import Gst, GstRtspServer, GObject
>> >
>> > class RTSP_Factory(GstRtspServer.RTSPMediaFactory):
>> >     def __init__(self, pipeline, clock):
>> >         self.clock=clock
>> >         self.pipeline = pipeline
>> >         GstRtspServer.RTSPMediaFactory.__init__(self)
>> >
>> >     def do_create_element(self, url):
>> >         self.pipeline.set_start_time(Gst.CLOCK_TIME_NONE)
>> >         return self.pipeline
>> >
>> >     def do_configure(self, media):
>> >         media.set_shared(True)
>> >
>> > Gst.init()
>> > GObject.threads_init()
>> > loop = GObject.MainLoop()
>> > Gst.debug_set_active(True)
>> > Gst.debug_set_default_threshold(4)
>> >
>> > mainpipeline = Gst.parse_launch("nvcamerasrc "
>> >                                 "! video/x-raw(memory:NVMM),
>> > width=(int)2592, height=(int)1458, format=(string)I420,
>> > framerate=(fraction)30/1 "
>> >                                 "! omxh264enc bitrate=4000000
>> > profile=2 control-rate=2 insert-sps-pps=true insert-aud=true
>> > insert-vui=true iframeinterval=20 "
>> >                                 "! video/x-h264,
>> > stream-format=byte-stream, profile=(string)main "
>> >                                 "! tee ! proxysink name=psink")
>> >
>> > rtsppipeline = Gst.parse_launch("proxysrc name=psrc is-live=true !
>> > queue name=rq max-size-buffers=3 ! h264parse ! rtph264pay name=pay0
>> > pt=96 config-interval=1")
>> >
>> > sysclock = Gst.SystemClock.obtain()
>> >
>> > psink = mainpipeline.get_by_name("psink")
>> > psrc = rtsppipeline.get_by_name("psrc")
>> >
>> > psrc.set_property("proxysink", psink)
>> >
>> > mainpipeline.use_clock(sysclock)
>> > rtsppipeline.use_clock(sysclock)
>> > mainpipeline.set_base_time(0)
>> > rtsppipeline.set_base_time(0)
>> > #mainpipeline.set_start_time(Gst.CLOCK_TIME_NONE)
>> > rtsppipeline.set_start_time(Gst.CLOCK_TIME_NONE)
>> >
>> > server = GstRtspServer.RTSPServer()
>> > mounts = server.get_mount_points()
>> > factory = RTSP_Factory(rtsppipeline, sysclock)
>> >
>> > mounts.add_factory("/test", factory)
>> > server.attach(None)
>> >
>> > mainpipeline.set_state(Gst.State.PLAYING)
>> > loop.run()
>> >
>> > Regards,
>> > Chris
>> > _______________________________________________
>> > gstreamer-devel mailing list
>> > [hidden email]
>> > https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

>> I asked similar question yesterday. Fortunately today after doing some
>> tests I have found why it does not work and how to fix it. When pipeline
>> goes to PLAYING state, it updates its base time to current time. To fix
>> this, you have to get base time from one pipeline and set it as base
>> time for second one. I do this just after setting state of 2nd one to
>> PLAYING.

>> You also should remove lines which change start time, this produces some
>> strange results.

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