public function __construct($callback = null, Config $config = null) { // check that the "-progress" function is available. $parser = new FfmpegParser($config); $available_commands = $parser->getCommands(); if (isset($available_commands['progress']) === false) { throw new Exception('Your version of FFmpeg cannot support the Native progress handler. Please use ProgressHandlerOutput instead.'); } parent::__construct($callback, $config); $this->_progress_file = null; }
/** * Sets a command on ffmpeg that sets a timelimit * * @access public * @author Oliver Lillie * @param string $timelimit_in_seconds * @return self */ public function setProcessTimelimit($timelimit_in_seconds) { $parser = new FfmpegParser($this->_config); $commands = $parser->getCommands(); if (isset($commands['timelimit']) === false) { throw new Exception('The -timelimit command is not supported by your version of FFmpeg.'); } if ($timelimit_in_seconds <= 0) { throw new Exception('The timelimit must be greater than 0 seconds.'); } $this->addCommand('-timelimit', $timelimit_in_seconds); return $this; }
/** * Sets a command on ffmpeg that sets a timelimit for the process. If this timelimit is exceeded then ffmpeg bails. * * @access public * @author Oliver Lillie * @param integer $timelimit_in_seconds The timelimit to impose in seconds. * @return PHPVideoToolkit\FfmpegProcess Returns the current object. * @throws PHPVideoToolkit\FfmpegProcessCommandUnavailableException If the timelimit command is not available on the configured ffmpeg. * @throws \InvalidArgumentException If the timelimit is not an integer. * @throws \InvalidArgumentException If the timelimit is less than or equal to 0. */ public function setProcessTimelimit($timelimit_in_seconds) { $parser = new FfmpegParser($this->_config); $commands = $parser->getCommands(); if (isset($commands['timelimit']) === false) { throw new FfmpegProcessCommandUnavailableException('The -timelimit command is not supported by your version of FFmpeg.'); } if (is_int($timelimit_in_seconds) === false) { throw new \InvalidArgumentException('The timelimit in seconds argument must be an integer.'); } else { if ($timelimit_in_seconds <= 0) { throw new \InvalidArgumentException('The timelimit must be greater than 0 seconds.'); } } $this->addCommand('-timelimit', $timelimit_in_seconds); return $this; }
<?php namespace PHPVideoToolkit; include_once './includes/bootstrap.php'; $ffmpeg = new FfmpegParser(); $is_available = $ffmpeg->isAvailable(); Trace::vars('$ffmpeg->isAvailable()', $is_available); $ffmpeg_version = $ffmpeg->getVersion(); Trace::vars('$ffmpeg->getVersion()', $ffmpeg_version); $has_ffmpeg_php_support = $ffmpeg->hasFfmpegPhpSupport(); Trace::vars('$ffmpeg->hasFfmpegPhpSupport()', $has_ffmpeg_php_support); $basic_ffmpeg_information = $ffmpeg->getFfmpegData(); Trace::vars('$ffmpeg->getFfmpegData()', $basic_ffmpeg_information); $basic_ffmpeg_information = $ffmpeg->getCommands(); Trace::vars('$ffmpeg->getCommands()', $basic_ffmpeg_information); $ffmpeg_formats = $ffmpeg->getFormats(); Trace::vars('$ffmpeg->getFormats()', $ffmpeg_formats); $ffmpeg_audio_codecs = $ffmpeg->getCodecs('audio'); Trace::vars('$ffmpeg->getCodecs(\'audio\')', $ffmpeg_audio_codecs); $ffmpeg_video_codecs = $ffmpeg->getCodecs('video'); Trace::vars('$ffmpeg->getCodecs(\'video\')', $ffmpeg_video_codecs); $ffmpeg_subtitle_codecs = $ffmpeg->getCodecs('subtitle'); Trace::vars('$ffmpeg->getCodecs(\'subtitle\')', $ffmpeg_subtitle_codecs); $ffmpeg_bitstream_filters = $ffmpeg->getBitstreamFilters(); Trace::vars('$ffmpeg->getBitstreamFilters()', $ffmpeg_bitstream_filters); $ffmpeg_filters = $ffmpeg->getFilters(); Trace::vars('$ffmpeg->getFilters()', $ffmpeg_filters); $ffmpeg_protocols = $ffmpeg->getProtocols(); Trace::vars('$ffmpeg->getProtocols()', $ffmpeg_protocols); $ffmpeg_pixel_formats = $ffmpeg->getPixelFormats();
/** * Constructor * * @access public * @author: Oliver Lillie * @param constant $input_output_type Either Format::INPUT or Format::OUTPUT. Defaults to OUTPUT. It determines the format * mode used to set various commands in the final ffmpeg exec call. * @param PHPVideoToolkit\Config $config The config object. * @throws \InvalidArgumentException If the $input_output_type is not valid. */ public function __construct($input_output_type = Format::OUTPUT, Config $config = null) { parent::__construct($config); $this->setType($input_output_type); $this->_additional_commands = array(); $this->_removed_commands = array(); $this->_media_object = null; $this->_format = array('quality' => null, 'format' => null, 'strictness' => null, 'preset_options_file' => null, 'threads' => null, 'threads_indexed' => null); $ffmpeg = new FfmpegParser(); $available_commands = $ffmpeg->getCommands(); if (isset($available_commands['crf'])) { $quality_command = '-crf <setting>'; } else { if (isset($available_commands['q']) === true) { $quality_command = '-q <setting>'; } else { $quality_command = '-qscale <setting>'; } } $this->_format_to_command = array('quality' => $quality_command, 'format' => '-f <setting>', 'strictness' => '-strict <setting>', 'preset_options_file' => '-fpre <setting>', 'threads' => '-threads <setting>', 'threads_indexed' => '-threads:<index> <setting>'); // add default input/output commands if ($input_output_type === self::OUTPUT) { if ($this->_config->set_default_output_format === true) { $this->setThreads(1)->setStrictness('experimental')->setQualityVsStreamabilityBalanceRatio(4); } } else { if ($input_output_type === self::INPUT) { } else { throw new \InvalidArgumentException('Unrecognised input/output type "' . $input_output_type . '" set in \\PHPVideoToolkit\\Format::__construct'); } } }