unset($_SESSION['process_id_multiple']);
         echo '<a href="?reset=1">Restart Process</a>';
         exit;
     }
     echo '<meta http-equiv="refresh" content="1; url=?' . time() . '">';
     echo '<a href="?reset=1">Reset Process</a>';
     exit;
 }
 Trace::vars('Starting new encode...');
 /**
  * MASSIVE MASSIVE README WARNING
  * Whilst it is technically possible to output 5 or even more media files from one encode request
  * it often takes much much longer to run. This of course is dependant on your server and you should run tests
  * to see what your server can handle before doing too many of these requests as you could kill your server.
  */
 $multi_output = new MultiOutput();
 $mp3_output = './output/big_buck_bunny.multi1.mp3';
 $format = Format::getFormatFor($mp3_output, null, 'AudioFormat');
 $multi_output->addOutput($mp3_output, $format);
 $ogg_output = './output/big_buck_bunny.multi2.ogg';
 $format = Format::getFormatFor($ogg_output, null, 'VideoFormat');
 $format->setVideoDimensions(VideoFormat::DIMENSION_SQCIF);
 $multi_output->addOutput($ogg_output, $format);
 $ogg_output = './output/big_buck_bunny.multi3.ogg';
 $format = Format::getFormatFor($ogg_output, null, 'VideoFormat');
 $format->setVideoDimensions(VideoFormat::DIMENSION_XGA);
 $multi_output->addOutput($ogg_output, $format);
 $threegp_output = './output/big_buck_bunny.multi4.3gp';
 $format = Format::getFormatFor($threegp_output, null, 'VideoFormat');
 $format->setVideoDimensions(VideoFormat::DIMENSION_XGA);
 $multi_output->addOutput($threegp_output, $format);
<?php

namespace PHPVideoToolkit;

namespace PHPVideoToolkit;

include_once './includes/bootstrap.php';
try {
    $video = new Video($example_video_path);
    $process = $video->getProcess();
    $video->extractSegment(new Timecode(10), new Timecode(20));
    $multi_output = new MultiOutput();
    $ogg_output = './output/big_buck_bunny.multi1.ogg';
    $format = Format::getFormatFor($ogg_output, null, 'VideoFormat');
    $format->setVideoDimensions(VideoFormat::DIMENSION_SQCIF);
    $multi_output->addOutput($ogg_output, $format);
    $threegp_output = './output/big_buck_bunny.multi2.3gp';
    $format = Format::getFormatFor($threegp_output, null, 'VideoFormat');
    $format->setVideoDimensions(VideoFormat::DIMENSION_XGA);
    $multi_output->addOutput($threegp_output, $format);
    $process = $video->save($multi_output, null, Media::OVERWRITE_EXISTING);
    echo '<h1>Executed Command</h1>';
    Trace::vars($process->getExecutedCommand());
    echo '<h1>Executed Command RAW</h1>';
    Trace::vars($process->getExecutedCommand(true));
    echo '<hr /><h1>FFmpeg Process Messages</h1>';
    Trace::vars($process->getMessages());
    echo '<hr /><h1>Buffer Output</h1>';
    Trace::vars($process->getBuffer(true));
    echo '<hr /><h1>Resulting Output</h1>';
    $output = $process->getOutput();
<?php

namespace PHPVideoToolkit;

include_once './includes/bootstrap.php';
echo '<a href="?method=blocking">Blocking</a> | <a href="?method=non-blocking">Non blocking</a><br />';
try {
    $video = new Video($example_video_path);
    $video->extractSegment(new Timecode(10), new Timecode(30));
    $process = $video->getProcess();
    $multi_output = new MultiOutput();
    $flv_output = './output/big_buck_bunny.multi1.ogg';
    $format = Format::getFormatFor($flv_output, null, 'VideoFormat');
    $format->setVideoDimensions(VideoFormat::DIMENSION_SQCIF);
    $multi_output->addOutput($flv_output, $format);
    $threegp_output = './output/big_buck_bunny.multi2.3gp';
    $format = Format::getFormatFor($threegp_output, null, 'VideoFormat');
    $format->setVideoDimensions(VideoFormat::DIMENSION_XGA);
    $multi_output->addOutput($threegp_output, $format);
    $threegp_output = './output/big_buck_bunny.multi3.3gp';
    $format = Format::getFormatFor($threegp_output, null, 'VideoFormat');
    $format->setVideoDimensions(VideoFormat::DIMENSION_XGA);
    $multi_output->addOutput($threegp_output, $format);
    if (isset($_GET['method']) === true && $_GET['method'] === 'blocking') {
        echo '<h2>Blocking Method</h2>';
        // If you use a blocking save but want to handle the progress during the block, then assign a callback within
        // the constructor of the progress handler.
        // IMPORTANT NOTE: most modern browser don't support output buffering any more.
        $progress_data = array();
        $progress_handler = new ProgressHandlerNative(function ($data) use(&$progress_data) {
            // do something here like log to file or db.
Exemplo n.º 4
0
 /**
  * Converts a string path and output format into a MultiOutput object.
  *
  * @access protected
  * @author Oliver Lillie
  * @param  string $save_path The string based path of a MultiObject.
  * @param  Format $output_format An output format object.
  * @return MultiObject
  */
 protected function _convertOutputPathToMultiOutput($save_path = null, Format $output_format = null)
 {
     $class = 'PHPVideoToolkit\\MultiOutput';
     // prevents unneccesary autoload.
     if ($save_path instanceof $class === true) {
         return $save_path;
     }
     $multi_output = new MultiOutput($this->_config);
     $multi_output->setDefaultOutputFormat($this->getDefaultFormatClassName());
     $multi_output->addOutput($save_path, $output_format);
     return $multi_output;
 }