protonemedia /
laravel-ffmpeg
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ProtoneMedia\LaravelFFMpeg\FFMpeg; |
||
| 4 | |||
| 5 | use FFMpeg\Format\FormatInterface; |
||
| 6 | use Illuminate\Support\Collection; |
||
| 7 | |||
| 8 | trait RebuildsCommands |
||
| 9 | { |
||
| 10 | use InteractsWithBeforeSavingCallbacks; |
||
| 11 | use InteractsWithHttpHeaders; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Builds the command using the underlying library and then |
||
| 15 | * prepends the input with the headers. |
||
| 16 | * |
||
| 17 | * @param \FFMpeg\Format\FormatInterface $format |
||
| 18 | * @param string $outputPathfile |
||
| 19 | * @return array |
||
| 20 | */ |
||
| 21 | protected function buildCommand(FormatInterface $format, $outputPathfile) |
||
| 22 | { |
||
| 23 | $command = parent::buildCommand($format, $outputPathfile); |
||
| 24 | |||
| 25 | $command = $this->rebuildCommandWithHeaders($command); |
||
| 26 | $command = $this->rebuildCommandWithCallbacks($command); |
||
| 27 | |||
| 28 | return $command; |
||
| 29 | } |
||
| 30 | |||
| 31 | private function rebuildCommandWithHeaders($command) |
||
| 32 | { |
||
| 33 | if (empty($this->headers)) { |
||
| 34 | return $command; |
||
| 35 | } |
||
| 36 | |||
| 37 | return Collection::make($command)->map(function ($command) { |
||
| 38 | return static::mergeBeforePathInput( |
||
| 39 | $command, |
||
| 40 | $this->getPathfile(), |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 41 | static::compileHeaders($this->headers) |
||
| 42 | ); |
||
| 43 | })->all(); |
||
| 44 | } |
||
| 45 | } |
||
| 46 |