protonemedia / laravel-ffmpeg

This package provides an integration with FFmpeg for Laravel. Laravel's Filesystem handles the storage of the files.
https://protone.media/en/blog/how-to-use-ffmpeg-in-your-laravel-projects
MIT License
1.63k stars 194 forks source link

openAdvanced doesn't include stream #526

Open DawidWetzler opened 2 weeks ago

DawidWetzler commented 2 weeks ago

Hi there,

I'm trying to open video to apply some advanced filters (complex filters) but it looks openAdvanced isn't properly working with MediaCollection.

I've shorten in completely to get the smallest reproducible version:

$media = new MediaCollection([
    Media::make('local', 'input.mp4'),
]);

$result = $ffmpeg->openAdvanced($media)
    ->export()
    ->toDisk('local')
    ->addFormatOutputMapping(new WebM(videoCodec: 'libvpx-vp9'), Media::make('local', 'output.webm'), [])
    ->dd();

// -y -threads 12 -vcodec libvpx-vp9 -b:v 1000k -acodec libvorbis -b:a 128k -f webm /var/www/html/storage/app/output.webm

Meanwhile this in raw phpffmpeg is working.

$ffmpeg = \FFMpeg\FFMpeg::create();
$video  = $ffmpeg->openAdvanced([storage_path('app/input.mp4')]);
$cmd = $video->map([], new WebM(videoCodec: 'libvpx-vp9'), storage_path('app/output.webm'))
            ->getFinalCommand();

dd($cmd);

//output: -y -i /var/www/html/storage/app/input.mp4 -map  -vcodec libvpx-vp9 -acodec libvorbis -b:a 128k -f webm /var/www/html/storage/app/output.webm

I'm not sure what's causing this but the chain led to ->open method where the media collection this is already empty.

This results in Output file #0 does not contain any stream. error from ffmpeg.