난 그냥이mjpeg 방송의 병목 현상은 어디에 있습니까?
<?php
//example /cli/watch.php?i=0&j=200
function get_one_jpeg($i) {
$path = "img";
//$f = fopen("$path/$i.jpg", "rb");
return file_get_contents("$path/$i.jpg");
}
ini_set('display_errors', 1);
# Used to separate multipart
$boundary = "my_mjpeg";
# We start with the standard headers. PHP allows us this much
//header("Connection: close");
header("Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0");
header("Cache-Control: private");
header("Pragma: no-cache");
header("Expires: -1");
header("Content-type: multipart/x-mixed-replace; boundary=$boundary");
# From here out, we no longer expect to be able to use the header() function
print "--$boundary\n";
# Set this so PHP doesn't timeout during a long stream
set_time_limit(0);
# Disable Apache and PHP's compression of output to the client
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
# Set implicit flush, and flush all current buffers
@ini_set('implicit_flush', 1);
for ($i = 0; $i < ob_get_level(); $i++)
ob_end_flush();
ob_implicit_flush(1);
# The loop, producing one jpeg frame per iteration
$i = $_GET['i'];
$j = $_GET['j'];
while ($i <= $j) {
# Per-image header, note the two new-lines
print "Content-type: image/jpeg\n\n";
# Your function to get one jpeg image
print get_one_jpeg($i);
# The separator
print "--$boundary\n";
# Sleeping for 0.1 seconds for 10 frames in second
usleep(100000);
$i++;
}
?>
처럼 PHP와 MJPEG 스트리밍하지만 이미지의 큰 범위를 설정하는 경우, 예를 들어, 0에서 300까지, 한정없는 때 브라우저에서 바로 표시를 중지하고 있습니다.
특정 프레임이나 순간이 아니며 다른 브라우저에서 표시되므로 Apache의 원인은 Apache라고 생각합니다.
나는 아파치 2.2.9와 2.2.21에서 시험해보고 같은 결과를 얻었다. IIS Express에서는 더욱 악화됩니다.
어떤 문제가있을 수 있습니까?
파일을 포함 할 때'$ _GET' 변수를 직접 사용하지 마십시오. 심각한 보안 문제가 발생할 수 있습니다! – gnur
의견을 보내 주셔서 감사합니다. 테스트 용으로 만 사용합니다. – Saito