From fa651da41abe4a3e6c27231bd0b499a1cd478173 Mon Sep 17 00:00:00 2001 From: Robert Gruendler Date: Sun, 3 Feb 2013 20:05:25 +0100 Subject: [PATCH] added possibility to set timeout --- src/FFMpeg/Binary.php | 9 ++++++++- src/FFMpeg/FFMpeg.php | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/FFMpeg/Binary.php b/src/FFMpeg/Binary.php index 00a6a11..46e2582 100644 --- a/src/FFMpeg/Binary.php +++ b/src/FFMpeg/Binary.php @@ -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; } /** diff --git a/src/FFMpeg/FFMpeg.php b/src/FFMpeg/FFMpeg.php index a2ef4b0..0a2acb6 100644 --- a/src/FFMpeg/FFMpeg.php +++ b/src/FFMpeg/FFMpeg.php @@ -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()));