Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere is the bottleneck in mjpeg broadcasting?
    primarykey
    data
    text
    <p>I'm streaming mjpeg with PHP just like this</p> <pre><code>&lt;?php //example /cli/watch.php?i=0&amp;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 &lt; 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 &lt;= $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++; } ?&gt; </code></pre> <p>But if I set a big range of images, for example, from 0 to 300, in indefinite time browser just stop showing.</p> <p>It's not a specific frame or moment of time, and shows in different browsers, so I think that the causer of it is Apache.</p> <p>I tried it under Apache 2.2.9 and 2.2.21 and get the same result. Under IIS Express it works even worse.</p> <p>What problem it can be?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload