added possibility to set timeout
This commit is contained in:
parent
d7bb7bd091
commit
fa651da41a
2 changed files with 10 additions and 1 deletions
|
|
@ -30,13 +30,19 @@ abstract class Binary implements AdapterInterface
|
||||||
*/
|
*/
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Integer
|
||||||
|
*/
|
||||||
|
protected $timeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binary constructor
|
* Binary constructor
|
||||||
*
|
*
|
||||||
* @param type $binary The path file to the binary
|
* @param type $binary The path file to the binary
|
||||||
* @param Logger $logger A logger
|
* @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)) {
|
if (!is_executable($binary)) {
|
||||||
throw new \FFMpeg\Exception\BinaryNotFoundException(sprintf('`%s` is not a valid binary', $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->binary = $binary;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
$this->timeout = $timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,8 @@ class FFMpeg extends Binary
|
||||||
|
|
||||||
$builder = ProcessBuilder::create($options);
|
$builder = ProcessBuilder::create($options);
|
||||||
$process = $builder->getProcess();
|
$process = $builder->getProcess();
|
||||||
|
$process->setTimeout($this->timeout);
|
||||||
|
|
||||||
|
|
||||||
$this->logger->addInfo(sprintf('FFmpeg executes command %s', $process->getCommandline()));
|
$this->logger->addInfo(sprintf('FFmpeg executes command %s', $process->getCommandline()));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue