$flv = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_BATH . 'to-be-processed/rickroll.flv'; if (isset($_GET['file'])) { // require the library require_once '../phpvideotoolkit.' . $use_version . '.php'; // temp directory $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_BATH . 'tmp/'; // start ffmpeg class $toolkit = new PHPVideoToolkit($tmp_dir); // set the flv input $toolkit->setInputFile($flv); // get the incoming stream position $stream_pos = isset($_GET['pos']) ? $_GET['pos'] : 0; // in this example we will enable bandwidth limiting at the extreme and is not really practicle for live purposes // it will only release 100 bytes of the file every second, thus it should take roughly 5 minutes to release a 29Mb file // it will also prevent the browser cache from retaining the file. $toolkit->flvStreamSeek($stream_pos, array('active' => true, 'packet_size' => $packet_size, 'packet_interval' => $packet_interval), false); exit; //<- exits } $size = filesize($flv); echo '<strong>Bandwidth Restrictions and Download Rate.</strong><br />'; echo 'The flv media is ' . $size . ' bytes, using the bandwidth speed limit of ' . $packet_interval . ' kb/s media should be completely loaded in roughly ' . round($size / ($packet_interval * 1024 * $packet_size), 1) . ' seconds.<br />'; echo 'This may not appear to be the case in the player as the player will buffer the contents, You should notice that after a while the player will re-buffer the file. This is because the file was not loaded directly but through this script which buffered the release of the flv.<br />'; echo 'However you can test this better by downloading <a href="example13.php?file=to-be-processed/rickroll.flv&pos=0&packet_size=' . $packet_size . '">this link</a>.<br />'; echo 'You should notice that the file is downloading as a normal file off the internet, however the flv will download at a extremely slowed rate (more like dial-up speed than broadband or DSL) even if you are testing this script on your localhost.<br />'; echo '<br />'; echo '<strong>Change the example bandwidth restriction.</strong><br />'; echo '<select onchange="document.location.href=\'' . $_SERVER['PHP_SELF'] . '?packet_size=\'+this.value"> <option label="5 kb/s (Dialup)" value="5"' . ($packet_size == '5' ? ' selected' : '') . '>5 kb/s (Dialup)</option> <option label="10 kb/s" value="10"' . ($packet_size == '10' ? ' selected' : '') . '>10 kb/s</option> <option label="20 kb/s" value="20"' . ($packet_size == '20' ? ' selected' : '') . '>20 kb/s</option>