Raspberry Pi as generic RTSP Camera

QVR Pro, QVR Pro Client, QVR Center and Surveillance Station
Post Reply
campusantu
Starting out
Posts: 24
Joined: Sat Jan 21, 2012 7:01 pm
Location: Italy

Raspberry Pi as generic RTSP Camera

Post by campusantu »

Hi guys, I'm trying to use my Raspberry Pi with a PiNoir camera as a surveillance camera.
I managed to stream a fluid (but with about 1 second lag) 1080p@30fps video using RTSP with

Code: Select all

raspivid -o - -t 0 -w 1920 -h 1080  -fps 30 -b 1000000 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
I can connect to the stream using VLC from a pc, but I'm not able to configure the camera in the Surveillance Station. Configuring the right IP and port, I get this error: "Failed to create the RTSP connection to the network camera. Please check if the RTSP port is correct and the RTSP sreaming access name is 'live.sdp' on the network camera."

My NAS is a TS-212 with latest firmware (4.1.0 build 20140612) and surveillance station 5.0.1 . I tried a couple of things with no results, can someone help me?
Thank you
AlastairStevenson
Experience counts
Posts: 2415
Joined: Wed Jan 08, 2014 10:34 pm

Re: Raspberry Pi as generic RTSP Camera

Post by AlastairStevenson »

OK, so, some queries on your configs:
Connection string and RTSP port using VLC?
UDP or TCP?
Codec info from VLC?
Brand/Model using in SS Pro? (presumably Generic RTSP)
Connection string in SS Pro including RTSP port?
TS-431+ for storage and media and a bunch of IP cams under Surveillance Station. TVS-473 as files backup and QVR Pro.
campusantu
Starting out
Posts: 24
Joined: Sat Jan 21, 2012 7:01 pm
Location: Italy

Re: Raspberry Pi as generic RTSP Camera

Post by campusantu »

Hi, with VLC I just need to open the network stream with this string: "rtsp://192.168.1.10:8554". I also tried with port 554 and managed to add a path (I tried with path /live.sdp), but while the stream opens with no problems in VLC, i have no luck with SS. Obviously when I changed config I changed both cvlc parameters on the Pi and vlc connection string on my pc
Yeah, I'm using Generic RTSP (I have SS 5.0.1, can't find SS Pro)

I didn't check if it was using UDP or TCP, i leaved them to default values. If I'd know what codec to use I could specify it in cvlc, but since I wasn't able to find what is supported by SS and what is not, I tried default with h264.

SS camera configuration:

Code: Select all

Camera Brand: Generic Model
Camera Model: Generic RTSP
HTTP URL: /
Camera Name: Camera1
IP Address: 192.168.1.10
RTSP Port: 8554
WAN IP Address: [empty]
RTSP WAN Port: 8554
User Name: [empty]
Password: [empty]
AlastairStevenson
Experience counts
Posts: 2415
Joined: Wed Jan 08, 2014 10:34 pm

Re: Raspberry Pi as generic RTSP Camera

Post by AlastairStevenson »

Your SS Pro camera settings look like they should work, and yes, it supports H.264 video decoding. And you have already tried using the default of 554 for the RTSP port. SS Pro is known to baulk at handling RTSP streaming when the port is 80, as a shot in the dark high port numbers may be problematic.
It's possible there is simply an incompatibility between the Rpi's cvlc and SS Pro's RTSP client. There are lots of variations and versions possible in RTSP implementations.
My only suggestion would be to check you get the same problem with a lower resolution/frame rate/bit rate, what you're trying is quite stretching for a TS-212. Maybe try -w 1080 -h 720 -fps 15 -b 500000
If I was troubleshooting this I'd run a network capture and analyse the RTSP session setup dialogue between Rpi and SS Pro to see where the mismatch is. But that's a bit low level and cryptic for a normal troubleshooting suggestion.
TS-431+ for storage and media and a bunch of IP cams under Surveillance Station. TVS-473 as files backup and QVR Pro.
campusantu
Starting out
Posts: 24
Joined: Sat Jan 21, 2012 7:01 pm
Location: Italy

Re: Raspberry Pi as generic RTSP Camera

Post by campusantu »

OK, I'll try in the next few days and report what I'll eventually discover. Thank you
campusantu
Starting out
Posts: 24
Joined: Sat Jan 21, 2012 7:01 pm
Location: Italy

Re: Raspberry Pi as generic RTSP Camera

Post by campusantu »

AlastairStevenson wrote:My only suggestion would be to check you get the same problem with a lower resolution/frame rate/bit rate, what you're trying is quite stretching for a TS-212. Maybe try -w 1080 -h 720 -fps 15 -b 500000
Tried 640x480@10fps 200Kbps, same result. So the problem is not high-load.
AlastairStevenson wrote:If I was troubleshooting this I'd run a network capture and analyse the RTSP session setup dialogue between Rpi and SS Pro to see where the mismatch is. But that's a bit low level and cryptic for a normal troubleshooting suggestion.
I installed WireShark on the RPi and started network capture. Meanwhile I started the cvlc streaming.

In SS I configured the camera and clicked test. Result:
  • About a dozen TCP messages exchanged between RPi and SS (SYN, ACK and PSH)
  • About a dozen SSDP messages from the NAS to an address that doesn't belong to my network (239.255.255.250, I assume a multicast group was created, but probably not for SS? I don't know)
  • Some UDP packets from raspberry IP to the broadcast address with extremely high port numbers (32412-32418)
In VLC I connected to the stream. Result:
  • Same TCP messages as with SS, this time between RPi and the pc
  • 3 ICMP Port unreachable packets
  • Same UDP packets from raspberry IP to the broadcast address as when connecting from SS, mixed with ...
  • ... a bunch of UDP packets from raspberry IP to the pc running VLC with the same port numbers (which should be the video stream)
Any suggestion?
In the RPi shell, the cvlc outputs prints "connection from ...." when I connect VLC, but nothing with SS. Can it be an incompatibility between cvlc and SS? Are there any other known-good programs to substitute cvlc for the streaming? Does the SS support RTP?
AlastairStevenson
Experience counts
Posts: 2415
Joined: Wed Jan 08, 2014 10:34 pm

Re: Raspberry Pi as generic RTSP Camera

Post by AlastairStevenson »

I'm guessing that cvlc is creating a UDP multicast stream. In the 5 or 6 cameras where I've examined their RTSP traffic to SS Pro, it's always requested TCP as the transport. I know that doesn't mean SS Pro doesn't support UDP, but it seems likely, or at least a default. And I couldn't find any documentation on cvlc to explain how it negotiates / agrees the transport.
A bit optimistic in terms of figuring the underlying cause (much less a fix), if you could drop a copy of the SS Pro network capture somewhere I could have a go at looking at it.

Here as an example is a fragment of an RTSP setup with a camera set in SS Pro as Generic RTSP. In frames 5 & 6 SS Pro requests and gets TCP as the transport.

Code: Select all

NAS:
OPTIONS rtsp://192.168.1.168:80/ch0_0.264 RTSP/1.0..CSeq: 1..User-Agent: NVR..Authorization: Basic YWRtaW46....
Camera:
RTSP/1.0 200 OK..CSeq: 1..Public: SETUP,OPTIONS,DESCRIBE,PLAY,TEARDOWN..Server: minirtsp 2.0 (by kaga)....
NAS:
DESCRIBE rtsp://192.168.1.168:80/ch0_0.264 RTSP/1.0..CSeq: 2..Accept: application/sdp..User-Agent: NVR..Authorization: Basic YWRtaW46...
Camera:
RTSP/1.0 200 OK..CSeq: 2..Content-Type: application/sdp..Content-Length: 265..Server: minirtsp 2.0 (by kaga)....v=0..o=- 1020876048 1 IN IP4 192.168.1.168..s=ch0_0.264..i=minisdp..c=IN IP4 192.168.1.168..t=0 0..a=control:*..m=audio 0 RTP/AVP 8..c=IN IP4 0.0.0.0..a=rtpmap:8 PCMA/8000..a=control:track=audio..m=video 0 RTP/AVP 96..a=rtpmap:96 H264/90000..a=control:track=video
NAS:
SETUP rtsp://192.168.1.168:80/ch0_0.264/track=video RTSP/1.0..CSeq: 3..User-Agent: NVR..Transport: RTP/AVP/TCP;unicast;interleaved=0-1..Authorization: Basic YWRtaW46....
Camera:
RTSP/1.0 200 OK..CSeq: 3..Session: 908404062..Transport: RTP/AVP/TCP;unicast;interleaved=0-1;ssrc=4317f..Server: minirtsp 2.0 (by kaga)....
NAS:
PLAY rtsp://192.168.1.168:80/ch0_0.264 RTSP/1.0..CSeq: 4..Session: 908404062..Range: npt=0.000-..Authorization: Basic YWRtaW46....
Camera:
RTSP/1.0 200 OK..CSeq: 4..Date: Thu, Jul 17 2014 12:17:16 GMT..Server: minirtsp 2.0 (by kaga)....
TS-431+ for storage and media and a bunch of IP cams under Surveillance Station. TVS-473 as files backup and QVR Pro.
campusantu
Starting out
Posts: 24
Joined: Sat Jan 21, 2012 7:01 pm
Location: Italy

Re: Raspberry Pi as generic RTSP Camera

Post by campusantu »

Here's a dump of wireshark capture. I just filtered ARP requests and packets to and from my pc. I wonder why they're TCP packets now. I made other trials but still no luck so I went back to the original command in the first post.

192.168.1.2 is the TS-212, 192.168.1.129 is the RPi.
I also tried using sdp=rtsp://:8554/trackID=0 (there are packets referring to that address).

Code: Select all

No.     Time           Source                Destination           Protocol Length Info
     15 5.533082000    192.168.1.2           239.255.255.250       SSDP     373    NOTIFY * HTTP/1.1 
     16 5.592812000    192.168.1.2           239.255.255.250       SSDP     364    NOTIFY * HTTP/1.1 
     17 5.652636000    192.168.1.2           239.255.255.250       SSDP     416    NOTIFY * HTTP/1.1 
     18 5.713006000    192.168.1.2           239.255.255.250       SSDP     428    NOTIFY * HTTP/1.1 
     19 5.772718000    192.168.1.2           239.255.255.250       SSDP     430    NOTIFY * HTTP/1.1 
     20 5.833028000    192.168.1.2           239.255.255.250       SSDP     444    NOTIFY * HTTP/1.1 
    702 44.042347000   192.168.1.2           192.168.1.129         TCP      74     49544 > rtsp-alt [SYN] Seq=0 Win=14600 Len=0 MSS=1460 SACK_PERM=1 TSval=58937059 TSecr=0 WS=128
    703 44.042714000   192.168.1.129         192.168.1.2           TCP      74     rtsp-alt > 49544 [SYN, ACK] Seq=0 Ack=1 Win=28960 Len=0 MSS=1460 SACK_PERM=1 TSval=166293 TSecr=58937059 WS=64
    704 44.043302000   192.168.1.2           192.168.1.129         TCP      66     49544 > rtsp-alt [ACK] Seq=1 Ack=1 Win=14720 Len=0 TSval=58937059 TSecr=166293
    705 44.043918000   192.168.1.2           192.168.1.129         RTSP     166    OPTIONS rtsp://192.168.1.129:8554/ RTSP/1.0
    706 44.044170000   192.168.1.129         192.168.1.2           TCP      66     rtsp-alt > 49544 [ACK] Seq=1 Ack=101 Win=28992 Len=0 TSval=166293 TSecr=58937060
    707 44.065718000   192.168.1.129         192.168.1.2           RTSP     190    Reply: RTSP/1.0 200 OK
    708 44.066400000   192.168.1.2           192.168.1.129         TCP      66     49544 > rtsp-alt [ACK] Seq=101 Ack=125 Win=14720 Len=0 TSval=58937062 TSecr=166295
    709 44.067547000   192.168.1.2           192.168.1.129         RTSP     192    DESCRIBE rtsp://192.168.1.129:8554/ RTSP/1.0
    710 44.106992000   192.168.1.129         192.168.1.2           TCP      66     rtsp-alt > 49544 [ACK] Seq=125 Ack=227 Win=28992 Len=0 TSval=166300 TSecr=58937062
    711 44.108678000   192.168.1.129         192.168.1.2           TCP      269    [TCP segment of a reassembled PDU]
    713 44.143509000   192.168.1.2           192.168.1.129         TCP      66     49544 > rtsp-alt [ACK] Seq=227 Ack=328 Win=15744 Len=0 TSval=58937070 TSecr=166300
    714 44.144244000   192.168.1.129         192.168.1.2           RTSP/SDP 416    Reply: RTSP/1.0 200 OK, with session description
    715 44.144904000   192.168.1.2           192.168.1.129         TCP      66     49544 > rtsp-alt [ACK] Seq=227 Ack=678 Win=16768 Len=0 TSval=58937070 TSecr=166303
    716 44.145259000   192.168.1.2           192.168.1.129         RTSP     221    SETUP rtsp://192.168.1.129:8554/trackID=0 RTSP/1.0
    717 44.145487000   192.168.1.129         192.168.1.2           TCP      66     rtsp-alt > 49544 [ACK] Seq=678 Ack=382 Win=30080 Len=0 TSval=166303 TSecr=58937070
    718 44.167299000   192.168.1.129         192.168.1.2           RTSP     213    Reply: RTSP/1.0 461 Unsupported transport
    719 44.169014000   192.168.1.2           192.168.1.129         RTSP     221    SETUP rtsp://192.168.1.129:8554/trackID=0 RTSP/1.0
    720 44.206976000   192.168.1.129         192.168.1.2           TCP      66     rtsp-alt > 49544 [ACK] Seq=825 Ack=537 Win=31104 Len=0 TSval=166310 TSecr=58937072
    721 44.209232000   192.168.1.129         192.168.1.2           RTSP     213    Reply: RTSP/1.0 461 Unsupported transport
    722 44.210779000   192.168.1.2           192.168.1.129         RTSP     194    SETUP rtsp://192.168.1.129:8554/trackID=0 RTSP/1.0
    723 44.211111000   192.168.1.129         192.168.1.2           TCP      66     rtsp-alt > 49544 [ACK] Seq=972 Ack=665 Win=32192 Len=0 TSval=166310 TSecr=58937076
    724 44.251031000   192.168.1.129         192.168.1.2           RTSP     213    Reply: RTSP/1.0 461 Unsupported transport
    725 44.252774000   192.168.1.2           192.168.1.129         TCP      66     49544 > rtsp-alt [FIN, ACK] Seq=665 Ack=1119 Win=19968 Len=0 TSval=58937080 TSecr=166314
    726 44.271891000   192.168.1.129         192.168.1.2           TCP      66     rtsp-alt > 49544 [FIN, ACK] Seq=1119 Ack=666 Win=32192 Len=0 TSval=166316 TSecr=58937080
    727 44.272629000   192.168.1.2           192.168.1.129         TCP      66     49544 > rtsp-alt [ACK] Seq=666 Ack=1120 Win=19968 Len=0 TSval=58937082 TSecr=166316
There are 461 errors (Unsupported Transport) but what does that exactly mean and how can I solve it? Why QNAP doesn't explicitly say what does SS accept?
AlastairStevenson
Experience counts
Posts: 2415
Joined: Wed Jan 08, 2014 10:34 pm

Re: Raspberry Pi as generic RTSP Camera

Post by AlastairStevenson »

Your network capture is showing that SS Pro and cvlc do not have a video streaming method in common.

Confirmation of the incompatibility between cvlc and SS Pro will be in the payload detail of the SS Pro SETUP requests, starting at frame 716 and repeating in the expectation that the RPi may come up with a different response. The RPi response to the likely "Transport: RTP/AVP/TCP;unicast;interleaved=0-1" request of SS Pro may have more detail in the payload of the '461 unsupported transport' responses, which will likely be saying 'sorry, I don't do TCP', or possibly 'sorry I don't do 0-1 interleave' but more likely UDP only.
So in effect, no common ground on the stream transport.
The solution would be a different player (as cvlc doesn't seem to have the more flexible streaming options of VLC) that can use TCP as opposed to UDP (I'm assuming that's what will be 'unsupported' as opposed to the 0-1 interleave).
It might be worth a QNAP Helpdesk request to find out if there is an undocumented way to make SS Pro do RTP over UDP on an H.264 video stream.
TS-431+ for storage and media and a bunch of IP cams under Surveillance Station. TVS-473 as files backup and QVR Pro.
campusantu
Starting out
Posts: 24
Joined: Sat Jan 21, 2012 7:01 pm
Location: Italy

Re: Raspberry Pi as generic RTSP Camera

Post by campusantu »

Ok, I guess I need to find some other way.. I gave a shot to gstreamer but at this point I'll need to go deeper. I'll try with QNAP Helpdesk, I never tried it but reading in this forum they seem to be not very fast to reply.
Thank you very much for your help. Eventually I'll go back here if I find something (but don't take this as a threat XD)
Post Reply

Return to “Surveillance Solution”