Completed
Push — master ( a002fc...0420c5 )
by Pascal
09:53 queued 07:49
created

SegmentedFilter::apply()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 14
nc 1
nop 2
1
<?php
2
3
namespace Pbmedia\LaravelFFMpeg;
4
5
use FFMpeg\Filters\Video\VideoFilterInterface;
6
use FFMpeg\Format\VideoInterface;
7
use FFMpeg\Media\Video;
8
9
class SegmentedFilter implements VideoFilterInterface
10
{
11
    protected $playlistPath;
12
13
    protected $segmentLength;
14
15
    protected $priority;
16
17
    public function __construct(string $playlistPath, int $segmentLength = 10, $priority = 0)
18
    {
19
        $this->playlistPath  = $playlistPath;
20
        $this->segmentLength = $segmentLength;
21
        $this->priority      = $priority;
22
    }
23
24
    public function getPlaylistPath(): string
25
    {
26
        return $this->playlistPath;
27
    }
28
29
    public function getSegmentLength(): int
30
    {
31
        return $this->segmentLength;
32
    }
33
34
    public function getPriority()
35
    {
36
        return $this->priority;
37
    }
38
39
    public function apply(Video $video, VideoInterface $format)
40
    {
41
        return [
42
            '-map',
43
            '0',
44
            '-flags',
45
            '-global_header',
46
            '-f',
47
            'segment',
48
            '-segment_format',
49
            'mpeg_ts',
50
            '-segment_list',
51
            $this->getPlaylistPath(),
52
            '-segment_time',
53
            $this->getSegmentLength(),
54
        ];
55
    }
56
}
57