Playing RTSP stream at an absolute timestamp

This forum is about all development around libVLC.
LordWhiro
New Cone
New Cone
Posts: 3
Joined: 20 Apr 2020 02:25

Playing RTSP stream at an absolute timestamp

Postby LordWhiro » 20 Apr 2020 02:52

Hi everyone!

Guys, I need your help badly. I need to play a stream recorded from an IP camera. It's a RTSP stream served by Milestone XProtect's ONVIF bridge (for those who know).
I have on URL for the stream : rtsp://192.168.137.196:554/vod/D88F96F3-D1F5-4A05-BAB3-E1A8009CF650
VLC Media Player plays it good, but... always from the start. I have 7 days of video footage, and each time I launch the stream, VLC starts it from the very beginning, and "sliding further" is not possible.

Here is a sample from the console (using "-vvv"), showing the RTSP exchange between my client and the server :

Code: Select all

Sending request: OPTIONS rtsp://192.168.137.196:554/vod/D88F96F3-D1F5-4A05-BAB3-E1A8009CF650 RTSP/1.0 CSeq: 2 User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2019.11.06) Received 208 new bytes of response data. Received a complete OPTIONS response: RTSP/1.0 200 OK CSeq: 2 Date: Mon, Apr 20 2020 00:09:03 GMT Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER Supported: play.basic, play.scale, setup.rtp.rtcp.mux Sending request: DESCRIBE rtsp://192.168.137.196:554/vod/D88F96F3-D1F5-4A05-BAB3-E1A8009CF650 RTSP/1.0 CSeq: 3 User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2019.11.06) Accept: application/sdp Received 170 new bytes of response data. Received a complete DESCRIBE response: RTSP/1.0 401 Unauthorized CSeq: 3 Date: Mon, Apr 20 2020 00:09:03 GMT WWW-Authenticate: Digest realm="RtspServerLibrary", nonce="A6Dl5quCyjPo9OCbl0Yzy8XcNncYMdO6" Resending... Sending request: DESCRIBE rtsp://192.168.137.196:554/vod/D88F96F3-D1F5-4A05-BAB3-E1A8009CF650 RTSP/1.0 CSeq: 4 Authorization: Digest username="admin", realm="RtspServerLibrary", nonce="A6Dl5quCyjPo9OCbl0Yzy8XcNncYMdO6", uri="rtsp://192.168.137.196:554/vod/D88F96F3-D1F5-4A05-BAB3-E1A8009CF650", response="bafe1f107003a143516e018dcefc4080" User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2019.11.06) Accept: application/sdp [000055c32501b1d0] qt interface debug: IM: Setting an input Received 1034 new bytes of response data. Received a complete DESCRIBE response: RTSP/1.0 200 OK CSeq: 4 Date: Mon, Apr 20 2020 00:09:03 GMT Supported: play.basic, play.scale, setup.rtp.rtcp.mux Content-base: rtsp://192.168.137.196:554/vod/D88F96F3-D1F5-4A05-BAB3-E1A8009CF650 Content-type: application/sdp Content-Length: 778 v=0 o=- 1587341343721651 1 IN IP4 127.0.0.1 s=libRtspServer c=IN IP4 0.0.0.0 t=0 0 a=tool:libRtspServer 1.0.0 a=range:npt=0.0-563733.7 a=range:clock=20200413T113328Z-20200413T180229Z;clock=20200413T182142Z-20200413T183743Z;clock=20200413T184242Z-20200413T213537Z;clock=20200413T213712Z-20200413T224433Z;clock=20200414T214842Z-20200414T231642Z;clock=20200415T074251Z-20200415T080405Z;clock=20200415T082609Z-20200415T183839Z;clock=20200416T082017Z-20200416T150512Z;clock=20200416T190047Z-20200416T193611Z;clock=20200416T220036Z-20200416T230506Z;clock=20200417T074825Z-20200417T154347Z;clock=20200419T085648Z-20200419T121145Z;clock=20200419T144845Z- m=video 0 RTP/AVP 96 a=framerate:1.000000 a=rtpmap:96 H264/90000 a=control:streamid=0 a=fmtp:96 packetization-mode=1; [00007f0cf80011a0] live555 demux debug: RTP subsession 'video/H264' Sending request: SETUP rtsp://192.168.137.196:554/vod/D88F96F3-D1F5-4A05-BAB3-E1A8009CF650/streamid=0 RTSP/1.0 CSeq: 5 Authorization: Digest username="admin", realm="RtspServerLibrary", nonce="A6Dl5quCyjPo9OCbl0Yzy8XcNncYMdO6", uri="rtsp://192.168.137.196:554/vod/D88F96F3-D1F5-4A05-BAB3-E1A8009CF650", response="e1e212e63c54dc4af516084fd402347e" User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2019.11.06) Transport: RTP/AVP;unicast;client_port=59114-59115 Received 235 new bytes of response data. Received a complete SETUP response: RTSP/1.0 200 OK CSeq: 5 Date: Mon, Apr 20 2020 00:09:03 GMT Session: C9DC4585 Transport: RTP/AVP;unicast;client_port=59114-59115;server_port=4000-4001 Media-Properties: Random-Access=2.5, Unlimited, Immutable, Scales="-16:16" [00007f0d00000c80] main input debug: selecting program id=0 [00007f0cf80011a0] live555 demux debug: setup start: 0,000000 stop:0,000000 Sending request: PLAY rtsp://192.168.137.196:554/vod/D88F96F3-D1F5-4A05-BAB3-E1A8009CF650 RTSP/1.0 CSeq: 6 Authorization: Digest username="admin", realm="RtspServerLibrary", nonce="A6Dl5quCyjPo9OCbl0Yzy8XcNncYMdO6", uri="rtsp://192.168.137.196:554/vod/D88F96F3-D1F5-4A05-BAB3-E1A8009CF650", response="3c1b8a89c5f630f673216a026c965ebe" User-Agent: LibVLC/3.0.8 (LIVE555 Streaming Media v2019.11.06) Session: C9DC4585 Range: npt=0.000- Received 221 new bytes of response data. Received a complete PLAY response: RTSP/1.0 200 OK Scale: 1 Range: npt=0.000- CSeq: 6 Date: Mon, Apr 20 2020 00:09:03 GMT Session: C9DC4585 RTP-Info: url=rtsp://192.168.137.196:554/vod/D88F96F3-D1F5-4A05-BAB3-E1A8009CF650;seq=43428;rtptime=6852


As you can see in the response of the DESCRIBE request, there are all the records I can play :
a=range:clock=20200413T113328Z-20200413T180229Z;clock=20200413T182142Z-20200413T183743Z;clock=20200413T184242Z-20200413T213537Z;clock=20200413T213712Z-20200413T224433Z;clock=20200414T214842Z-20200414T231642Z;clock=20200415T074251Z-20200415T080405Z;clock=20200415T082609Z-20200415T183839Z;clock=20200416T082017Z-20200416T150512Z;...

But HOW can I tell VLC to start playing the stream at a given, absolute, time? What is the syntax? I tried many many ways, still the PLAY request specifies Range: npt=0.000- so I understand I only have the beginning.
Also, what is the correct code to do it using libvlc in C/C++ ? I already have a graphical integration but I need to specify an absolute time to start the stream.

Please help me, I've been searching 2 weeks without success, and I'm under pressure because I'm late for delivery...

Kind regards

Boris

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Playing RTSP stream at an absolute timestamp

Postby sherington » 20 Apr 2020 15:36

I don't know about playing RTSP streams specifically, but generally you can specify a start time (and end-time or duration if you want too), e.g. from the command line --start-time=30.

Or if you use LibVLC, you pass e.g. ":start-time=30" as a media option when you play the media.

The value is a number of seconds, and you can pass fractional values like 30.5.

Maybe worth a try.

LordWhiro
New Cone
New Cone
Posts: 3
Joined: 20 Apr 2020 02:25

Re: Playing RTSP stream at an absolute timestamp

Postby LordWhiro » 20 Apr 2020 16:25

Thanks for answering sherington, but I already tried this. This doesn't work, my stream still plays from "Range: npt=0.000-" with that parameter.

I went further in my investigations and I managed to reach the time I wanted in my stream by... a very dirty way: I wrote a proxy TCP program that is placed between my VLC client and the RTSP server. Its orders are to forward the packets in both directions, except that when it finds "npt=0.000-" in an outbound packet, it replaces it by an absolute value like "clock=20200419T150000Z-".
It works, but it's very dirty and I don't think I can deliver such a "tricky" (and expensive) solution.
I would like to be able to do this using the regular libVLC api.

So hey VLC guys, what have I missed?

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Playing RTSP stream at an absolute timestamp

Postby Rémi Denis-Courmont » 20 Apr 2020 22:17

You can't tell VLC to start at an absolute time. There's simply no such concept. It's up to the RTSP plugin to map relative time to whatever is appropriate for the specific stream.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

LordWhiro
New Cone
New Cone
Posts: 3
Joined: 20 Apr 2020 02:25

Re: Playing RTSP stream at an absolute timestamp

Postby LordWhiro » 21 Apr 2020 18:42

Wow. You sound like it's normal. It's OK because VLC is free but hey, if you're saying this feature has no reason to be, I strongly disgree (with respect that you're a VLC developer, so you know what you're talking about).
VLC can be used to play IP cameras replay streams right? So when you're doing that, you want to play the stream at an absolute time, giving date and time. RTSP RFC specification allows this in standard, so why wouldn't it be a good idea?

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Playing RTSP stream at an absolute timestamp

Postby Rémi Denis-Courmont » 21 Apr 2020 19:02

It's not about the feature being justified or not. I am merely stating the facts that it simply does not exist at this time in VLC, and never did. As such the only way to handle RTSP absolute times is for the RTSP plugin to map VLC relative time to RTSP absolute time.

As for my opinion: mapping relative to absolute seems saner than exposing absolute time in VLC. Both because of the relative effort, and because of the GUI concept or lack thereof, notably w.r.t. the time slider.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

User avatar
InTheWings
Developer
Developer
Posts: 1275
Joined: 07 Aug 2013 13:15
VLC version: crashing
Operating System: Linux
Contact:

Re: Playing RTSP stream at an absolute timestamp

Postby InTheWings » 21 Apr 2020 20:20

Thanks for answering sherington, but I already tried this. This doesn't work, my stream still plays from "Range: npt=0.000-" with that parameter.

I went further in my investigations and I managed to reach the time I wanted in my stream by... a very dirty way: I wrote a proxy TCP program that is placed between my VLC client and the RTSP server. Its orders are to forward the packets in both directions, except that when it finds "npt=0.000-" in an outbound packet, it replaces it by an absolute value like "clock=20200419T150000Z-".
It works, but it's very dirty and I don't think I can deliver such a "tricky" (and expensive) solution.
I would like to be able to do this using the regular libVLC api.

So hey VLC guys, what have I missed?
We don't control the library which must provide support
:!: If you want your problem to be solved :
* First read troubleshooting guide VSG:Main
* Always provide verbose LOGS ! (command line or from gui)
* Always check your issue against a developer build from Nightly Build of VLC
* Tell us when your problem is solved !


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 26 guests