1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Soluble\MediaTools\Video\Config; |
6
|
|
|
|
7
|
|
|
use Soluble\MediaTools\Common\Process\ProcessParamsInterface; |
8
|
|
|
use Soluble\MediaTools\Video\ProcessParams; |
9
|
|
|
|
10
|
|
|
class FFProbeConfig implements FFProbeConfigInterface |
11
|
|
|
{ |
12
|
|
|
public const DEFAULT_BINARY = 'ffmpeg'; |
13
|
|
|
public const DEFAULT_TIMEOUT = null; |
14
|
|
|
public const DEFAULT_IDLE_TIMEOUT = null; |
15
|
|
|
public const DEFAULT_ENV = []; |
16
|
|
|
|
17
|
|
|
/** @var string */ |
18
|
|
|
protected $binary; |
19
|
|
|
|
20
|
|
|
/** @var ProcessParamsInterface */ |
21
|
|
|
protected $processParams; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param string $ffprobeBinary FFProbeBinary, by default ffprobe |
25
|
|
|
* @param float|null $timeout max allowed time (in seconds) for conversion, null for no timeout |
26
|
|
|
* @param float|null $idleTimeout max allowed idle time (in seconds) for conversion, null for no timeout |
27
|
|
|
* @param array<string, string|int> $env An array of additional env vars to set when running the ffprobe process |
28
|
|
|
*/ |
29
|
|
|
public function __construct( |
30
|
|
|
string $ffprobeBinary = self::DEFAULT_BINARY, |
31
|
|
|
?float $timeout = self::DEFAULT_TIMEOUT, |
32
|
|
|
?float $idleTimeout = self::DEFAULT_IDLE_TIMEOUT, |
33
|
|
|
array $env = self::DEFAULT_ENV |
34
|
|
|
) { |
35
|
|
|
$this->binary = $ffprobeBinary; |
36
|
|
|
$this->processParams = new ProcessParams( |
37
|
|
|
$timeout, |
38
|
|
|
$idleTimeout, |
39
|
|
|
$env |
40
|
|
|
); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function getBinary(): string |
44
|
|
|
{ |
45
|
|
|
return $this->binary; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getProcessParams(): ProcessParamsInterface |
49
|
|
|
{ |
50
|
|
|
return $this->processParams; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|