<div dir="ltr">Doh! Looks like I might have missed this:<div><br></div><div>In my factory subclass:</div><div>
<p class=""><span class="">self.set_media_gtype(MyRTSPMediaType)</span></p><div class="gmail_extra"><br></div><div class="gmail_extra">Which should reference:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">class MyRTSPMediaType(GstRtspServer.RTSPMedia):</div><div class="gmail_extra"> def do_setup_rtpbin(self, rtpbin):</div><div class="gmail_extra"> rtpbin.set_property('ntp-time-source', 'clock-time')</div><div class="gmail_extra"> return(rtpbin)</div><div class="gmail_extra"><br></div><div class="gmail_extra">And suddenly my timestamp issues seem to go away :)</div><div><br></div></div><div class="gmail_extra"><div class="gmail_quote">On 29 May 2016 at 23:07, Jonathan Thorpe <span dir="ltr"><<a href="mailto:jt@jonthorpe.net" target="_blank">jt@jonthorpe.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Hi All,</div><div><br></div><div>Sebastian - thank you so much for pointing me in the right direction with this earlier. It was very helpful in allowing me to progress with this and I have finally had a chance to put some code together.</div><div><br></div><div>I have written an RTSP server in Python trying to re-implement the code that was in test-netclock.c / test-netclock-client.c, however I have a few problems with synchronisation. I must be close.</div><div><br></div><div>My server is configured with a pipeline as follows:</div><div><br></div><div>My launch string for the factory on the server is as follows:</div><div>
<p><span>udpsrc uri=udp://<a href="http://127.0.0.1:6001" target="_blank">127.0.0.1:6001</a> caps="application/x-rtp, media=(string)audio, clock-rate=(int)44100, channels=(int)2, format=(string)S16LE" ! rtpL16depay ! audioconvert ! audioresample ! opusenc bitrate=96000 inband-fec=1 ! rtpopuspay name=pay0</span></p><p>It captures raw audio through RTP on port 6001 and converts it to OPUS. which will be sent out to the clients (which should all play out in sync).</p><p>For this factory, I'm also setting:</p><p>factory.set_shared(True)<br>factory.set_retransmission_time(5000)<br>factory.set_clock(clock)<br>factory.set_profiles(GstRtsp.RTSPProfile.AVPF)</p></div><div><div>Where clock is a time provider that I want to run from the server and use that to sync the clients:</div><div><br></div><div>clock = Gst.SystemClock.obtain()</div><div><span>clock_provider = GstNet.NetTimeProvider.new(clock, </span><span>None</span><span>, 8555</span><span>)</span></div></div><div><br></div><div>On my clients, where I have sync=true on my alsaaudiosink, I get about 2 seconds of audio followed by silence and a lot of this:</div><div>
<p><span>audiobasesink gstaudiobasesink.c:1807:gst_audio_base_sink_get_alignment:<autoaudiosink0-actual-sink-alsa> Unexpected discontinuity in audio timestamps of +1012391:15:11.969041666, resyncing<br>
</span></p><p><span>audiobasesink gstaudiobasesink.c:1512:gst_audio_base_sink_skew_slaving:<autoaudiosink0-actual-sink-alsa> correct clock skew -0:00:00.020016938 < -+0:00:00.020000000</span></p><p><span>The client comprises the following pipeline (location is the server and buffer is usually configured as 1000 or 5000)</span></p><p><span>
</span></p><p>My client contains the following:<br></p><p>self.pipeline = Gst.parse_launch('rtspsrc location=%s latency=%s buffer-mode=synced ntp-time-source=clock-time ntp-sync=1 do-rtcp=true ! rtpopusdepay name=pay0 ! opusdec ! audioconvert ! autoaudiosink sync=true async=false' % (src, latency))</p><p># make a clock slaving to the network<br>self.clock = GstNet.NetClientClock.new('clock0', clock_ip, clock_port, 0)</p><p># Wait for initial clock sync<br>self.clock.wait_for_sync(Gst.CLOCK_TIME_NONE)</p><p>self.pipeline.use_clock(self.clock)<br>self.pipeline.set_start_time(Gst.CLOCK_TIME_NONE)<br>self.pipeline.set_latency(latency * Gst.MSECOND)</p><p>self.pipeline.set_state(Gst.State.PLAYING)<br></p><p># Wait until error or EOS.<br>self.bus = self.pipeline.get_bus()<br>self.bus.add_signal_watch()<br>self.bus.connect('message', self.bus_handler)</p><p>The intention for this set up is to:<br>1. Buffer 1-5 seconds of audio.<br>2. Within this buffer period, allow for retransmits.<br>3. Otherwise, keep the clients in sync with the server's clock using the GST NetClientClock.</p></div><div>This configuration plays audio fine if I change "sync=false" on the audio sink, but this also breaks synchronisation.</div><div><br></div><div>Any pointers as to what I've done wrong? I'm currently running GStreamer out of git.</div><div><br></div><div>Kind Regards,</div><div>Jonathan</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
Message: 5<br>
Date: Mon, 25 Apr 2016 09:24:53 +0300<br>
From: Sebastian Dröge <<a href="mailto:sebastian@centricular.com" target="_blank">sebastian@centricular.com</a>><br>
To: Discussion of the development of and with GStreamer<br>
<<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a>><br>
Subject: Re: Synchronised RTP Clients<br>
Message-ID: <<a href="mailto:1461565493.2297.107.camel@centricular.com" target="_blank">1461565493.2297.107.camel@centricular.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
On Mo, 2016-04-25 at 13:19 +1000, Jonathan Thorpe wrote:<br>
> <br>
> I have clearly chosen a very complex project to get started with<br>
> GStreamer on, but would be very grateful if someone could assist with<br>
> helping establish pipelines (Client and Server) that will achieve<br>
> this.<br>
<br>
Take a look at my presentation from last year's GStreamer conference:<br>
<a href="https://gstconf.ubicast.tv/videos/synchronised-multi-room-media-playback-and-distributed-live-media-processing-and-mixing-with-gstreamer/" rel="noreferrer" target="_blank">https://gstconf.ubicast.tv/videos/synchronised-multi-room-media-playback-and-distributed-live-media-processing-and-mixing-with-gstreamer/</a><br>
<br>
Also these two example applications are basically doing exactly what<br>
you want, just with the GStreamer netclock instead of PTP. But<br>
exchanging that is a matter of changing a couple of lines.<br>
<br>
<a href="https://cgit.freedesktop.org/gstreamer/gst-rtsp-server/tree/examples/test-netclock.c" rel="noreferrer" target="_blank">https://cgit.freedesktop.org/gstreamer/gst-rtsp-server/tree/examples/test-netclock.c</a><br>
<a href="https://cgit.freedesktop.org/gstreamer/gst-rtsp-server/tree/examples/test-netclock-client.c" rel="noreferrer" target="_blank">https://cgit.freedesktop.org/gstreamer/gst-rtsp-server/tree/examples/test-netclock-client.c</a><br>
<br>
The examples are using RTSP and gst-rtsp-server, but there's nothing<br>
RTSP specific in how all this works. It's just for simplicity to make<br>
it easier to exchange the SDP between sender and clients.<br>
<br>
--<br>
Sebastian Dröge, Centricular Ltd · <a href="http://www.centricular.com" rel="noreferrer" target="_blank">http://www.centricular.com</a><br>
<br>
-------------- next part --------------<br>
A non-text attachment was scrubbed...<br>
Name: signature.asc<br>
Type: application/pgp-signature<br>
Size: 949 bytes<br>
Desc: This is a digitally signed message part<br>
URL: <<a href="https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160425/31cca1a2/attachment-0001.sig" rel="noreferrer" target="_blank">https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160425/31cca1a2/attachment-0001.sig</a>><br>
<br>
------------------------------<br>
<br>
Message: 6<br>
Date: Mon, 25 Apr 2016 09:20:48 +0100<br>
From: Andy Robinson <<a href="mailto:andy@seventhstring.com" target="_blank">andy@seventhstring.com</a>><br>
To: <a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
Subject: Re: How to query the GstSegment "rate"?<br>
Message-ID: <<a href="mailto:571DD360.10109@seventhstring.com" target="_blank">571DD360.10109@seventhstring.com</a>><br>
Content-Type: text/plain; charset=utf-8; format=flowed<br>
<br>
On 25/04/16 07:21, Sebastian Dröge wrote:<br>
> On Sa, 2016-04-23 at 14:55 +0100, Andy Robinson wrote:<br>
>> I imagine there must be some way of querying the<br>
>> pipeline for the rate once it is in paused state, but how?<br>
><br>
> You could try the SEGMENT query, if something in your pipeline is<br>
> answering it then it will contain the rate.<br>
><br>
> But the bigger question is why you need to query the rate and don't<br>
> know it already. In the end it was your code that was setting that<br>
> exact rate via a seek :)<br>
><br>
><br>
> Also what's the bigger picture here? Why do you want to convert from<br>
> stream time to the scaled stream time by rate (which is not exactly the<br>
> running time in general, but maybe you actually want the running<br>
> time?)?<br>
><br>
<br>
Even if I don't do any seek, a Segment event goes down the pipeline and<br>
it has a rate of 0.5 - I know this from putting diagnostics in the pipeline.<br>
<br>
The file is here if you are interested:<br>
<a href="http://www.seventhstring.com/other2/JAttendraiShort50.mov" rel="noreferrer" target="_blank">http://www.seventhstring.com/other2/JAttendraiShort50.mov</a><br>
It plays ok in Parole Media Player on Linux, or QuickTime on Mac. It's<br>
60 secs long and was produced, using QuickTime, by slowing down a 30 sec<br>
clip to half speed.<br>
<br>
When I play it in my app, I find that when I want to seek using<br>
gst_element_seek_simple within this video I must use the pre-slowdown<br>
times, e.g. if I want to seek to the 40th second of the 60 second video,<br>
I must actually seek to a time of 20 secs, and also must make a similar<br>
adjustment to the values returned by gst_element_query_position.<br>
<br>
It seems to me that I need to get that 0.5 rate number and use it as a<br>
multiplier when I call gst_element_seek_simple but if there is a better<br>
way, please advise me.<br>
<br>
Of course, maybe the file is simply erroneous, illegal, though it does<br>
play ok in some (not all) players.<br>
<br>
Regards,<br>
Andy Robinson, Seventh String Software, <a href="http://www.seventhstring.com" rel="noreferrer" target="_blank">www.seventhstring.com</a><br>
<br>
<br>
------------------------------<br>
<br>
Message: 7<br>
Date: Mon, 25 Apr 2016 08:28:23 +0200<br>
From: marc dingemans <<a href="mailto:marcdingemans62@gmail.com" target="_blank">marcdingemans62@gmail.com</a>><br>
To: <a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
Subject: muliple gst_element_seek for creating new file<br>
Message-ID:<br>
<CAN2V=<a href="mailto:fCEOhsBCx8YPfWdiL5OXcdYHQEcqP1cED0vO_V49SdC9A@mail.gmail.com" target="_blank">fCEOhsBCx8YPfWdiL5OXcdYHQEcqP1cED0vO_V49SdC9A@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi<br>
<br>
I want to extract some video parts from a mkv file and create based on<br>
these parts one new mkv file.<br>
<br>
This is done with muliple gst_element_seek calls with a time frame.<br>
When a eos is received, then a the next gst_element_seek is started until<br>
done.<br>
The destination file is generated, but can not be played with VLC.<br>
The seek is done executed on element "matroskademux" (also used pipeline)<br>
with GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SNAP_BEFORE properties<br>
<br>
Used pipeline :<br>
filesrc| matroskademux| h264parse | matroskamux | filesink<br>
<br>
<br>
When I use next pipeline, then everything works fine.<br>
filesrc| matroskademux| h264parse | avdec_h264| autovideosink<br>
<br>
<br>
Why does the seek seems work to gui and not to file.<br>
Must I use other approaches to put parts from a file in a new one<br>
<br>
Thanks for your help<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160425/407be008/attachment.html" rel="noreferrer" target="_blank">https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160425/407be008/attachment.html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<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>
<br>
<br>
------------------------------<br>
<br>
End of gstreamer-devel Digest, Vol 63, Issue 76<br>
***********************************************<br>
</blockquote></div><br></div></div>
</blockquote></div><br></div></div></div>