Issues (76)

src/Exporters/HandlesConcatenation.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace ProtoneMedia\LaravelFFMpeg\Exporters;
4
5
use ProtoneMedia\LaravelFFMpeg\Filesystem\Media;
6
7
trait HandlesConcatenation
8
{
9
    /**
10
     * @var boolean
11
     */
12
    protected $concatWithTranscoding = false;
13
14
    /**
15
     * @var boolean
16
     */
17
    protected $concatWithVideo = false;
18
19
    /**
20
     * @var boolean
21
     */
22
    protected $concatWithAudio = false;
23
24
    public function concatWithTranscoding(bool $hasVideo = true, bool $hasAudio = true): self
25
    {
26
        $this->concatWithTranscoding = true;
27
        $this->concatWithVideo       = $hasVideo;
28
        $this->concatWithAudio       = $hasAudio;
29
30
        return $this;
31
    }
32
33
    private function addConcatFilterAndMapping(Media $outputMedia)
34
    {
35
        $sources = $this->driver->getMediaCollection()->map(function ($media, $key) {
36
            return "[{$key}]";
37
        });
38
39
        $concatWithVideo = $this->concatWithVideo ? 1 : 0;
40
        $concatWithAudio = $this->concatWithAudio ? 1 : 0;
41
42
        $this->addFilter(
0 ignored issues
show
It seems like addFilter() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        $this->/** @scrutinizer ignore-call */ 
43
               addFilter(
Loading history...
43
            $sources->implode(''),
44
            "concat=n={$sources->count()}:v={$concatWithVideo}:a={$concatWithAudio}",
45
            '[concat]'
46
        )->addFormatOutputMapping($this->format, $outputMedia, ['[concat]']);
47
    }
48
}
49