<div dir="ltr">Thank you for the tip, Fabián! I was not aware of segment seeking, it definitely seems like a better way to loop. However, it didn't entirely solve my problem. The video stream loops, but the client (in this case, gst-play-1.0) closes the connection because it expects the video stream to only last as long as the video file's original run time.<div><br></div><div>I looked into the way gst-rtsp-server determines run time, and I found the "gst_rtsp_stream_query_stop" method does this by reading the pipeline's current segment stop time. Since the stop time will in my case always be the end of the video, gst-rtsp-server assumes that to be the run time of the stream. I was able to get around this by overriding RTSPMedia.do_query_stop to always return -1, which causes gst-rtsp-server to assume this is an unending source.<div><br></div><div>If anyone knows a more elegant solution I would be interested to hear it, but for the time being this seems to work well.<br><div><br></div><div>My complete RTSPMedia subclass looks like this:</div><div><br></div><div><font face="monospace">class RTSPMedia(GstRtspServer.RTSPMedia):<br>    def do_query_stop(self, _stop):<br>        return -1<br><br>    def do_handle_message(self, message: Gst.Message):<br>        if message.type == Gst.MessageType.STATE_CHANGED:<br>            # Set up segment seeking once the pipeline starts playing<br>            pipeline = self.get_property("element")<br>            _, new_state, _ = message.parse_state_changed()<br>            if message.src == pipeline and new_state == Gst.State.PLAYING:<br>                seek_result = pipeline.seek(<br>                    rate=1.0,<br>                    format=Gst.Format.TIME,<br>                    flags=Gst.SeekFlags.FLUSH | Gst.SeekFlags.SEGMENT,<br>                    start_type=Gst.SeekType.SET,<br>                    start=0,<br>                    stop_type=Gst.SeekType.NONE,<br>                    stop=-1)<br>                if not seek_result:<br>                    raise RuntimeError(f"Failed to send seek event")<br>        elif message.type == Gst.MessageType.SEGMENT_DONE:<br>            # Seek playback to the start when the segment is done<br>            seek_result = pipeline.seek(<br>                rate=1.0,<br>                format=Gst.Format.TIME,<br>                flags=Gst.SeekFlags.SEGMENT,<br>                start_type=Gst.SeekType.SET,<br>                start=0,<br>                stop_type=Gst.SeekType.NONE,<br>                stop=-1)<br>            if not seek_result:<br>                raise RuntimeError(f"Failed to send seek event")<br><br>        return GstRtspServer.RTSPMedia.do_handle_message(self, message)</font><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 29, 2020 at 8:03 PM Fabián Orccón <<a href="mailto:cfoch.fabian@gmail.com">cfoch.fabian@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Hello,<br>Do a SEGMENT seek to 0.0 when you receive Gst.MessageType.SEGMENT_DONE.<br></div><div><br></div><div><br></div>\o<div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 29, 2020 at 9:45 PM Tyler Compton <<a href="mailto:xaviosx@gmail.com" target="_blank">xaviosx@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi list,<div><br></div><div>I've been trying to create an RTSP stream from a video file source and have the video loop back to the start when it ends. This has ended up being quite tricky and I suspect I'm missing something obvious. My pipeline looks something like this:</div><div><br></div><div>filesrc location=video.mp4 ! parsebin ! rtph264pay name=pay0</div><div><br></div><div>My current solution is to subclass RTSPMedia and override the do_handle_message method. I capture EOS messages and seek the pipeline back to the start. However, this doesn't seem to have any effect. The stream just ends like normal.</div><div><br></div><font face="monospace">class MyRTSPMedia(GstRtspServer.RTSPMedia):<br>    def do_handle_message(self, message):<br>        print("Got message:", message.type)<br>        if message.type == Gst.MessageType.EOS:<br>            pipeline: Gst.Pipeline = self.get_property("element")<br>            seek_result = pipeline.seek(<br>                rate=1.0,<br>                format=Gst.Format.TIME,<br>                flags=Gst.SeekFlags.FLUSH,<br>                start_type=Gst.SeekType.SET,<br>                start=0,<br>                stop_type=Gst.SeekType.NONE,<br>                stop=-1)<br>            if not seek_result:<br>                logging.error(<br>                    f"Failed to seek stream back to start! Seek "<br>                    f"returned {seek_result}")<br>            return True<br>        return GstRtspServer.RTSPMedia.do_handle_message(self, message)<br></font><div><br></div><div>I provide this class to my RTSPMediaFactory with the set_media_gtype method.</div><div><br></div><div>I noticed that gst-rtsp-server reports the video length to the client, so the client expects the stream to only last for as long as the original video. I would like the client to treat the source as a live, unending stream. Is it possible that this inaccurate runtime is the source of my problem?</div></div>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div></div></div>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div>