* @package PHPVideoToolkit * @license BSD * @copyright Copyright (c) 2008 Oliver Lillie * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software * is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * @see JEROEN WIJERING Flash Media Player, * - @link http://www.jeroenwijering.com/?item=JW_FLV_Media_Player * - @author Jeroen Wijering. */ // set the packet details as we are restricting the bandwidth // the default details set here mean 5kb per second, ie dialup speed. $packet_size = isset($_GET['packet_size']) ? intval($_GET['packet_size']) : (isset($_COOKIE['packet_size']) ? intval($_COOKIE['packet_size']) : 5); $packet_interval = 1; setcookie('packet_size', $packet_size, time()+7200, '/'); if(!isset($_GET['file'])) { echo ''; echo '← Back to examples list

'; echo 'This example shows how to simply create an FLV stream script.
'; echo '• The flash media player used below is Jeroen Wijering\'s excellent Flash Media Player. Although bundled with this package the Flash Media Player has a Creative Commons Attribution-Noncommercial-Share Alike 2.0 Generic license.
'; echo '• The media is embedded using PluginObject to embed the examples. It is distributed under a BSD License.

'; } // load the examples configuration $ignore_config_output = true; require_once '../example-config.php'; // set the flv file $flv = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'to-be-processed'.DS.'rickroll.flv'; // require the library require_once '../../phpvideotoolkit.'.$use_version.'.php'; // temp directory $tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_PATH.'working'.DS.'tmp'.DS; // start ffmpeg class $toolkit = new PHPVideoToolkit($tmp_dir); if(isset($_GET['file'])) { // 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 'Bandwidth Restrictions and Download Rate.
'; echo 'The flv media is '.$size.' bytes, using the bandwidth speed limit of '.$packet_size.' kb/s media should be completely loaded in roughly '.$toolkit->formatSeconds(round($size/($packet_interval*1024*$packet_size*2), 1), '%hh hours, %mm minutes, %ss.%ms seconds').'.
'; 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.
'; echo 'However you can test this better by downloading this link.
'; 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.
'; echo '
'; echo 'Change the example bandwidth restriction.
'; echo '


'; // echo '';