當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Video::extractSegment方法代碼示例

本文整理匯總了PHP中Video::extractSegment方法的典型用法代碼示例。如果您正苦於以下問題:PHP Video::extractSegment方法的具體用法?PHP Video::extractSegment怎麽用?PHP Video::extractSegment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Video的用法示例。


在下文中一共展示了Video::extractSegment方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Video

<?php

namespace PHPVideoToolkit;

include_once './includes/bootstrap.php';
try {
    $video = new Video($example_video_path);
    $process = $video->extractSegment(new Timecode(10), new Timecode(20))->save('./output/test-' . time() . '.mp3', null, Media::OVERWRITE_EXISTING);
    echo '<h1>Executed Command</h1>';
    Trace::vars($process->getExecutedCommand());
    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>';
    Trace::vars($process->getOutput()->getMediaPath());
} catch (FfmpegProcessOutputException $e) {
    echo '<h1>Error</h1>';
    Trace::vars($e);
    $process = $video->getProcess();
    if ($process->isCompleted()) {
        echo '<hr /><h2>Executed Command</h2>';
        Trace::vars($process->getExecutedCommand());
        echo '<hr /><h2>FFmpeg Process Messages</h2>';
        Trace::vars($process->getMessages());
        echo '<hr /><h2>Buffer Output</h2>';
        Trace::vars($process->getBuffer(true));
    }
} catch (Exception $e) {
    echo '<h1>Error</h1>';
    Trace::vars($e->getMessage());
開發者ID:kunitwru,項目名稱:phpvideotoolkit-v2,代碼行數:31,代碼來源:extract-mp3-test.php

示例2: Video

<?php

namespace PHPVideoToolkit;

include_once './includes/bootstrap.php';
try {
    $video = new Video($example_video_path);
    //  $process->setProcessTimelimit(1);
    $process = $video->extractSegment(new Timecode(10), new Timecode(20))->save('./output/big_buck_bunny.flv', null, Media::OVERWRITE_EXISTING);
    echo '<h1>Executed Command</h1>';
    Trace::vars($process->getExecutedCommand());
    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>';
    Trace::vars($process->getOutput()->getMediaPath());
} catch (FfmpegProcessOutputException $e) {
    echo '<h1>Error</h1>';
    Trace::vars($e);
    $process = $video->getProcess();
    if ($process->isCompleted()) {
        echo '<hr /><h2>Executed Command</h2>';
        Trace::vars($process->getExecutedCommand());
        echo '<hr /><h2>FFmpeg Process Messages</h2>';
        Trace::vars($process->getMessages());
        echo '<hr /><h2>Buffer Output</h2>';
        Trace::vars($process->getBuffer(true));
    }
} catch (Exception $e) {
    echo '<h1>Error</h1>';
開發者ID:kunitwru,項目名稱:phpvideotoolkit-v2,代碼行數:31,代碼來源:convert-to-flv.php

示例3: Video

<?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.
開發者ID:kunitwru,項目名稱:phpvideotoolkit-v2,代碼行數:31,代碼來源:convert-to-multiple-output-progress-handler-native.php

示例4: Video

            $config->gif_transcoder = 'gifsicle';
        } else {
            if ($gif_transcoder === 'gifsicle-with-convert') {
                $config->convert = $convert;
                $config->gif_transcoder = 'gifsicle';
            } else {
                if ($gif_transcoder === 'convert') {
                    $config->convert = $convert;
                    $config->gif_transcoder = 'convert';
                }
            }
        }
        $output_format = Format::getFormatFor($output_path, $config, 'ImageFormat');
        $output_format->setVideoFrameRate(12);
        $video = new Video($example_video_path, $config);
        $process = $video->extractSegment(new Timecode(10), new Timecode(30))->save($output_path, $output_format, Media::OVERWRITE_EXISTING);
        $length = microtime_float() - $start;
        echo '<h1>' . str_replace('-', ' ', $gif_transcoder) . '</h1>';
        echo 'File = ' . $output_path . '<br />';
        echo 'Time to encode = ' . $length . '<br />';
        echo 'File size = ' . filesize($output_path) / 1024 / 1024 . ' MB<br />';
    }
} catch (FfmpegProcessOutputException $e) {
    echo '<h1>Error</h1>';
    Trace::vars($e->getMessage());
    echo '<h2>FfmpegProcessOutputException</h2>';
    Trace::vars($e);
    $process = $video->getProcess();
    if ($process->isCompleted()) {
        echo '<hr /><h2>Executed Command</h2>';
        Trace::vars($process->getExecutedCommand());
開發者ID:kunitwru,項目名稱:phpvideotoolkit-v2,代碼行數:31,代碼來源:convert-to-animated-gif.php

示例5: Video

<?php

namespace PHPVideoToolkit;

include_once './includes/bootstrap.php';
try {
    $video = new Video($example_video_path);
    $video->extractSegment(new Timecode(15));
    $process = $video->save('./output/big_buck_bunny.my_silly_custom_file_extension', new ImageFormat_Jpeg('output'), Media::OVERWRITE_EXISTING);
    echo '<h1>Executed Command</h1>';
    Trace::vars($process->getExecutedCommand());
    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>';
    Trace::vars($process->getOutput()->getMediaPath());
} catch (FfmpegProcessOutputException $e) {
    echo '<h1>Error</h1>';
    Trace::vars($e);
    $process = $video->getProcess();
    if ($process->isCompleted()) {
        echo '<hr /><h2>Executed Command</h2>';
        Trace::vars($process->getExecutedCommand());
        echo '<hr /><h2>FFmpeg Process Messages</h2>';
        Trace::vars($process->getMessages());
        echo '<hr /><h2>Buffer Output</h2>';
        Trace::vars($process->getBuffer(true));
    }
} catch (Exception $e) {
    echo '<h1>Error</h1>';
開發者ID:kunitwru,項目名稱:phpvideotoolkit-v2,代碼行數:31,代碼來源:custom-file-extension.php

示例6: Video

<?php

namespace PHPVideoToolkit;

include_once './includes/bootstrap.php';
ob_start();
echo '<p>This is an example to chain processing on from one output to another to another and so on.</p><hr />';
echo '<p>.mov status: <strong id="status-1">---</strong></p>';
echo '<p>resize mov status: <strong id="status-2">---</strong></p>';
echo '<p>jpeg from resized mov status: <strong id="status-3">---</strong></p>';
ob_flush();
try {
    $video = new Video($example_video_path);
    $progress_handler = new ProgressHandlerNative();
    $process = $video->extractSegment(new Timecode(10), new Timecode(20))->saveNonBlocking('./output/big_buck_bunny.mov', null, Media::OVERWRITE_EXISTING, $progress_handler);
    $dot_count = -1;
    while ($progress_handler->completed !== true) {
        $dot_count += 1;
        $data = $progress_handler->probe(true);
        if ($data['started'] === true) {
            echo '<script>document.getElementById("status-1").innerHTML = ' . json_encode('Encoding to mov ' . $data['percentage'] . '% ' . str_pad('', $dot_count, '.')) . '</script>';
            echo '&nbsp;';
            ob_flush();
            //sleep(1);
            if ($dot_count > 10) {
                $dot_count = -1;
            }
        } else {
            echo '<script>document.getElementById("status-1").innerHTML = ' . json_encode('Waiting for encoding to start') . '</script>';
            echo '&nbsp;';
            ob_flush();
開發者ID:kunitwru,項目名稱:phpvideotoolkit-v2,代碼行數:31,代碼來源:chaining-processes.php

示例7: Video

<?php

namespace PHPVideoToolkit;

include_once './includes/bootstrap.php';
try {
    $video = new Video($example_video_path);
    //  $process->setProcessTimelimit(1);
    $process = $video->extractSegment(new Timecode(10), new Timecode(20))->save('./output/big_buck_bunny.ogg');
    echo '<h1>Executed Command</h1>';
    Trace::vars($process->getExecutedCommand());
    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>';
    Trace::vars($process->getOutput()->getMediaPath());
} catch (FfmpegProcessOutputException $e) {
    echo '<h1>Error</h1>';
    Trace::vars($e);
    $process = $video->getProcess();
    if ($process->isCompleted()) {
        echo '<hr /><h2>Executed Command</h2>';
        Trace::vars($process->getExecutedCommand());
        echo '<hr /><h2>FFmpeg Process Messages</h2>';
        Trace::vars($process->getMessages());
        echo '<hr /><h2>Buffer Output</h2>';
        Trace::vars($process->getBuffer(true));
    }
} catch (Exception $e) {
    echo '<h1>Error</h1>';
開發者ID:kunitwru,項目名稱:phpvideotoolkit-v2,代碼行數:31,代碼來源:convert-to-ogg.php

示例8: Video

<?php

namespace PHPVideoToolkit;

include_once './includes/bootstrap.php';
try {
    $video = new Video($example_video_path);
    //  $process->setProcessTimelimit(1);
    $process = $video->extractSegment(new Timecode(10), new Timecode(20))->save('./output/big_buck_bunny.mp3', new AudioFormat_Mp3('output'), Media::OVERWRITE_EXISTING);
    echo '<h1>Executed Command</h1>';
    Trace::vars($process->getExecutedCommand());
    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>';
    Trace::vars($process->getOutput()->getMediaPath());
} catch (FfmpegProcessOutputException $e) {
    echo '<h1>Error</h1>';
    Trace::vars($e);
    $process = $video->getProcess();
    if ($process->isCompleted()) {
        echo '<hr /><h2>Executed Command</h2>';
        Trace::vars($process->getExecutedCommand());
        echo '<hr /><h2>FFmpeg Process Messages</h2>';
        Trace::vars($process->getMessages());
        echo '<hr /><h2>Buffer Output</h2>';
        Trace::vars($process->getBuffer(true));
    }
} catch (Exception $e) {
    echo '<h1>Error</h1>';
開發者ID:kunitwru,項目名稱:phpvideotoolkit-v2,代碼行數:31,代碼來源:convert-to-mp3.php


注:本文中的Video::extractSegment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。