/
YadifVideoFilter.php
58 lines (48 loc) · 1.84 KB
/
YadifVideoFilter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
declare(strict_types=1);
/**
* @see https://github.com/soluble-io/soluble-mediatools for the canonical repository
*
* @copyright Copyright (c) 2018-2020 Sébastien Vanvelthem. (https://github.com/belgattitude)
* @license https://github.com/soluble-io/soluble-mediatools/blob/master/LICENSE.md MIT
*/
namespace Soluble\MediaTools\Video\Filter;
use Soluble\MediaTools\Video\Filter\Type\FFMpegVideoFilterInterface;
use Soluble\MediaTools\Video\Filter\Type\VideoDeinterlacerInterface;
final class YadifVideoFilter implements FFMpegVideoFilterInterface, VideoDeinterlacerInterface
{
public const DEFAULT_MODE = 0;
public const DEFAULT_PARITY = -1;
public const DEFAULT_DEINT = 0;
/** @var array<string, int> */
private $defaultOptions = [
'mode' => self::DEFAULT_MODE,
'parity' => self::DEFAULT_PARITY,
'deint' => self::DEFAULT_DEINT,
];
/** @var array<string, int> */
private $options = [];
/**
* @param int $mode The interlacing mode to adopt (0, send_frame Output one frame for each frame)
* @param int $parity default=-1 Enable automatic detection of field parity. 0:
* @param int $deint Specify which frames to deinterlace (0: all - Deinterlace all frames.)
*/
public function __construct(int $mode = self::DEFAULT_MODE, int $parity = self::DEFAULT_PARITY, int $deint = self::DEFAULT_DEINT)
{
$this->options = array_merge($this->defaultOptions, [
'mode' => $mode,
'parity' => $parity,
'deint' => $deint,
]);
}
public function getFFmpegCLIValue(): string
{
$yadifArg = sprintf(
'yadif=mode=%s:parity=%s:deint=%s',
$this->options['mode'],
$this->options['parity'],
$this->options['deint']
);
return $yadifArg;
}
}