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.62k stars 193 forks source link

Unable to create tile #514

Closed willPHPwork closed 7 months ago

willPHPwork commented 7 months ago

Getting the following error when using an MP4 video to export a tile:

[image2 @ 0x55949eb7bd00] Could not get frame filename number 2 from pattern '/tmp/108cf10699253adb/tiles/example-tile.jpg'. Use '-frames:v 1' for a single image, or '-update' option, or use a pattern such as %03d within the filename.
av_interleaved_write_frame(): Invalid argument
frame=    2 fps=0.5 q=3.6 Lsize=N/A time=00:00:18.40 bitrate=N/A speed= 4.9x    
video:22kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
$frameInterval = 1;
$video= FFMpeg::openUrl('https://cdn.example.com/link/to/video.mp4');
$video->exportTile(function (TileFactory $factory) use($frameInterval) {
                        $factory->interval($frameInterval)
                                  ->scale(200)
                                  ->grid(3, 2);
                          })
                    ->toDisk('aws')
                    ->withVisibility('public')
                        ->save($tile);

Any ideas why this error is occurring? Works fine with other videos, but some fail with this error.

ColorsCL commented 7 months ago

I think you trying to export more frames than your tile can contain (grid limitation), FFMPEG is trying to create more tile files but doesn't know how to name them...

Possible fix 1: If you add the pattern to your filename (%03d) you should be fine Possible fix 2: if you only want 1 tile file you should adapt the $frameInterval according to the grid (3x2 = max 6 frames per tile)

willPHPwork commented 7 months ago

1 worked for me,

Thanks!