DigPit DigPit - 3 months ago 27
Python Question

RTSP: cannot get session identifier

I am trying to control an ip cam using a python script (I can see the stream with VLC or mplayer).

After received OPTIONS and DESCRIBE informations, every SETUP I try give me an error:

SETUP rtsp://192.168.0.41:554/xxxxxx RTSP/1.0
CSeq: 3
Transport: RTP/AVP/UDP;unicast;client_port=3056-3057

RTSP/1.0 400 Bad Request
Allow: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER,USER_CMD_SET


so I never receive the session identification.

Maybe the problem is in the Transport line, but I think it's because I do not know what to put in place of the xxxxxxx (I tried and googled a lot but with non results)

Here are the output of OPTIONS and DESCRIBE:

OPTIONS rtsp://192.168.0.41:554 RTSP/1.0
CSeq: 1

RTSP/1.0 200 OK
CSeq: 1
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER,USER_CMD_SET


---------------------------------
DESCRIBE rtsp://192.168.0.41:554/onvif2 RTSP/1.0
CSeq: 2

RTSP/1.0 200 OK
CSeq: 2
Content-Type: application/sdp
Content-Length: 360

v=0
o=- 1421069297525233 1 IN IP4 192.168.0.41
s=H.264 Video, RtspServer_0.0.0.2
t=0 0
a=tool:RtspServer_0.0.0.2
a=type:broadcast
a=control:*
a=range:npt=0-
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:500
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=42001F;sprop-parameter-sets=Z0IAH5WoFAFuQA==,aM48gA==
a=control:track1


What that * stands for?

And what is "track1"?

(note: if I check for onvif1, that is the other streaming sent by the cam, the result is the same, but with track2, that means that the server answer should be appropriate)

Answer

Finally I discovered the problem: missing \r\n in the last python code line!

wrong:

Transport: RTP/AVP/UDP;unicast;client_port=52318-52319

correct:

Transport: RTP/AVP/UDP;unicast;client_port=52318-52319\r\n

Now it works.

Comments