Merge pull request #26 from pulse00/timeout-patch

added possibility to set timeout
This commit is contained in:
Romain Neutron 2013-02-04 03:44:40 -08:00
commit 55e978fa65
2 changed files with 10 additions and 1 deletions

View file

@ -30,13 +30,19 @@ abstract class Binary implements AdapterInterface
*/
protected $logger;
/**
* @var Integer
*/
protected $timeout;
/**
* Binary constructor
*
* @param type $binary The path file to the binary
* @param Logger $logger A logger
* @param Integer $timeout The timout for the underlying process
*/
public function __construct($binary, Logger $logger)
public function __construct($binary, Logger $logger, $timeout = 60)
{
if (!is_executable($binary)) {
throw new \FFMpeg\Exception\BinaryNotFoundException(sprintf('`%s` is not a valid binary', $binary));
@ -44,6 +50,7 @@ abstract class Binary implements AdapterInterface
$this->binary = $binary;
$this->logger = $logger;
$this->timeout = $timeout;
}
/**

View file

@ -179,6 +179,8 @@ class FFMpeg extends Binary
$builder = ProcessBuilder::create($options);
$process = $builder->getProcess();
$process->setTimeout($this->timeout);
$this->logger->addInfo(sprintf('FFmpeg executes command %s', $process->getCommandline()));