1

I am trying to establish a RTSP session with cURL and PHP. I am working with an IP camera and I want to reproduce its stream in a video tag of html5, but as it does not accept RTSP, I want to create an application that extracts the video and send it to the video tag.

To do this, I have studied RTSP and monitorized with Wireshark how it creates a session when being reproduced in VLC. My first problem is that I send a DESCRIBE request that is responded, but then my script is blocked waiting for something. Comparated to the VLC case, I think that I need to send another DESCRIBE request with a response parameter obtained with md5 using the nonce and other parameters.

My first DESCRIBE request has the difference from the VLC request that I don't know why it adds the header If-Modified-Since:. I don't know if it can be something relevant, but I don't know how to delete it.

This is my script:

<?php
$url = "rtsp://admin@43.201.36.211:88/videoMain";  
$curl = curl_init();
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RTSP_STREAM_URI, $url);
curl_setopt($curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_DESCRIBE);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'User-Agent: LibVLC/2.2.1 (LIVE555 Streaming Media v2014.07.25)'));
$res = curl_exec($curl);
echo 'unblocked';
curl_close($curl);
?>

and this is what I capture with Wireshark:

DESCRIBE rtsp://admin@43.201.36.211:88/videoMain RTSP/1.0
CSeq: 1
Accept: application/sdp
If-Modified-Since: Thu, 01 Jan 1970 00:00:00 GMT
User-Agent: LibVLC/2.2.1 (LIVE555 Streaming Media v2014.07.25)

RTSP/1.0 401 Unauthorized
CSeq: 1
Date: Fri, Jan 02 1970 00:12:26 GMT
WWW-Authenticate: Digest realm="LIVE555 Streaming Media", nonce="84bbbd02eda797825d5524e5aefc428b"

while this is what I capture when I use VLC to reproduce the stream from the IPCam:

[...]

DESCRIBE rtsp://43.201.36.211:88/videoMain RTSP/1.0
CSeq: 3
User-Agent: LibVLC/2.2.1 (LIVE555 Streaming Media v2014.07.25)
Accept: application/sdp

RTSP/1.0 401 Unauthorized
CSeq: 3
Date: Thu, Jan 01 1970 23:09:39 GMT
WWW-Authenticate: Digest realm="LIVE555 Streaming Media", nonce="787d041314f1ed2bff411529e888f5d9"

DESCRIBE rtsp://43.201.36.211:88/videoMain RTSP/1.0
CSeq: 4
Authorization: Digest username="admin", realm="LIVE555 Streaming Media", nonce="787d041314f1ed2bff411529e888f5d9", uri="rtsp://43.201.36.211:88/videoMain", response="8737471393ee8ecb93dbf96bed7f5609"
User-Agent: LibVLC/2.2.1 (LIVE555 Streaming Media v2014.07.25)
Accept: application/sdp

RTSP/1.0 200 OK
CSeq: 4
Date: Thu, Jan 01 1970 23:09:39 GMT
Content-Base: rtsp://43.201.36.211:65534/videoMain/
Content-Type: application/sdp
Content-Length: 492

v=0
o=- 1141547641 1 IN IP4 192.168.233.233
s=IP Camera Video
i=videoMain
t=0 0
a=tool:LIVE555 Streaming Media v2013.01.25
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:IP Camera Video
a=x-qt-text-inf:videoMain
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=42001E;sprop-parameter-sets=Z0IAHpWoKA9k,aM48gA==
a=control:track1
m=audio 0 RTP/AVP 0
c=IN IP4 0.0.0.0
b=AS:64
a=control:track2

[...]
Kiko
  • 99
  • 1
  • 14
  • This may be helpful: https://stackoverflow.com/questions/28022432/receiving-rtp-packets-after-rtsp-setup/28188102#28188102 – Kiko May 31 '16 at 10:31

0 Answers0