-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproxy_mjpeg_error.php
More file actions
37 lines (31 loc) · 831 Bytes
/
proxy_mjpeg_error.php
File metadata and controls
37 lines (31 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
// config:
$mjpeg_url = "http://mywebcam:8080/?action=stream";
// preparing http options:
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
);
$context = stream_context_create($opts);
// set no time limit and disable compression:
set_time_limit(0);
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
/* Sends an http request
* with additional headers shown above */
$fp = fopen($mjpeg_url, 'r', false, $context);
if ($fp) {
// send mjpeg header:
header("Cache-Control: no-cache");
header("Cache-Control: private");
header("Pragma: no-cache");
header("Content-type: multipart/x-mixed-replace; boundary=boundarydonotcross");
// pass data
fpassthru($fp);
fclose($fp);
} else {
Header("Service Unavailable", true, 503);
}