FFmpeg::output PHP Метод

output() публичный Метод

public output ( string $output = null, string $forceFormat = null ) : object
$output string Output file path @param string $forceFormat Force format output @return object @access public
$forceFormat string
Результат object
    public function output($output = null, $forceFormat = null)
    {
        $this->forceFormat($forceFormat);
        $options = array();
        foreach ($this->options as $option => $values) {
            if (is_array($values)) {
                $items = array();
                foreach ($values as $item => $val) {
                    if (!is_null($val)) {
                        if (is_array($val)) {
                            print_r($val);
                            $val = join(',', $val);
                        }
                        $val = strval($val);
                        if (is_numeric($item) and is_integer($item)) {
                            $items[] = $val;
                        } else {
                            $items[] = $item . "=" . $val;
                        }
                    } else {
                        $items[] = $item;
                    }
                }
                $options[] = "-" . $option . " " . join(',', $items);
            } else {
                $options[] = "-" . $option . " " . strval($values);
            }
        }
        $this->command = $this->ffmpeg . " " . join(' ', $options) . " " . $output . $this->STD;
        return $this;
    }

Usage Example

Пример #1
0
<?php

/**
*	include FFmpeg class
**/
include DIRNAME(DIRNAME(__FILE__)) . '/src/ffmpeg.class.php';
/**
*	get options from database
**/
$options = array('duration' => 99, 'position' => 0, 'itsoffset' => 2);
/**
*	Create command
*/
$FFmpeg = new FFmpeg('/usr/local/bin/ffmpeg');
$FFmpeg->input('/var/media/original.avi');
$FFmpeg->transpose(0)->vflip()->grayScale()->vcodec('h264')->frameRate('30000/1001');
$FFmpeg->acodec('aac')->audioBitrate('192k');
foreach ($options as $option => $values) {
    $FFmpeg->call($option, $values);
}
$FFmpeg->output('/var/media/new.mp4', 'mp4');
print $FFmpeg->command;