aminyazdanpanah /
PHP-FFmpeg-video-streaming
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | /** |
||||||
| 4 | * This file is part of the PHP-FFmpeg-video-streaming package. |
||||||
| 5 | * |
||||||
| 6 | * (c) Amin Yazdanpanah <[email protected]> |
||||||
| 7 | * |
||||||
| 8 | * For the full copyright and license information, please view the LICENSE |
||||||
| 9 | * file that was distributed with this source code. |
||||||
| 10 | */ |
||||||
| 11 | |||||||
| 12 | |||||||
| 13 | namespace Streaming; |
||||||
| 14 | |||||||
| 15 | |||||||
| 16 | use FFMpeg\Format\VideoInterface; |
||||||
| 17 | |||||||
| 18 | class CommandBuilder |
||||||
| 19 | { |
||||||
| 20 | /** @var Media */ |
||||||
| 21 | private $media; |
||||||
| 22 | |||||||
| 23 | /** @var \FFMpeg\Filters\FiltersCollection */ |
||||||
| 24 | private $filters; |
||||||
| 25 | |||||||
| 26 | /** @var \FFMpeg\Driver\FFMpegDriver */ |
||||||
| 27 | private $driver; |
||||||
| 28 | |||||||
| 29 | /** @var VideoInterface */ |
||||||
| 30 | private $format; |
||||||
| 31 | |||||||
| 32 | /** |
||||||
| 33 | * CommandBuilder constructor. |
||||||
| 34 | * @param Media $media |
||||||
| 35 | * @param VideoInterface $format |
||||||
| 36 | */ |
||||||
| 37 | public function __construct(Media $media, VideoInterface $format) |
||||||
| 38 | { |
||||||
| 39 | $this->media = $media; |
||||||
| 40 | $this->filters = $this->media->getFiltersCollection(); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
It seems like
$this->media->getFiltersCollection() of type FFMpeg\Media\Video or Streaming\Media is incompatible with the declared type FFMpeg\Filters\FiltersCollection of property $filters.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||||||
| 41 | $this->driver = $this->media->getFFMpegDriver(); |
||||||
|
0 ignored issues
–
show
The method
getFFMpegDriver() does not exist on Streaming\Media. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
It seems like
$this->media->getFFMpegDriver() of type FFMpeg\Media\Video or Streaming\Media is incompatible with the declared type FFMpeg\Driver\FFMpegDriver of property $driver.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||||||
| 42 | $this->format = $format; |
||||||
| 43 | } |
||||||
| 44 | |||||||
| 45 | /** |
||||||
| 46 | * @param VideoInterface $format |
||||||
| 47 | * @param string $path |
||||||
| 48 | * @return array |
||||||
| 49 | * @TODO: optimize this function |
||||||
| 50 | */ |
||||||
| 51 | public function build(VideoInterface $format, string $path): array |
||||||
| 52 | { |
||||||
| 53 | $commands = []; |
||||||
| 54 | |||||||
| 55 | foreach ($this->filters as $filter) { |
||||||
| 56 | $commands = array_merge($this->getInputOptions(), $filter->apply($this->media->baseMedia(), $format)); |
||||||
| 57 | } |
||||||
| 58 | |||||||
| 59 | if ($this->driver->getConfiguration()->has('ffmpeg.threads')) { |
||||||
| 60 | $commands = array_merge($commands, ['-threads', $this->driver->getConfiguration()->get('ffmpeg.threads')]); |
||||||
| 61 | } |
||||||
| 62 | |||||||
| 63 | array_push($commands, $path); |
||||||
| 64 | |||||||
| 65 | return $commands; |
||||||
| 66 | } |
||||||
| 67 | |||||||
| 68 | /** |
||||||
| 69 | * @return array |
||||||
| 70 | */ |
||||||
| 71 | private function getInputOptions(): array |
||||||
| 72 | { |
||||||
| 73 | $path = $this->media->getPathfile(); |
||||||
|
0 ignored issues
–
show
The method
getPathfile() does not exist on Streaming\Media. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 74 | $input_options = Utiles::arrayToFFmpegOpt($this->media->getInputOptions()); |
||||||
| 75 | |||||||
| 76 | return array_merge($input_options, $this->format->getInitialParameters() ?? [], ['-y', '-i', $path]); |
||||||
| 77 | } |
||||||
| 78 | } |