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

how to limit thumbnails count ? #439

Closed magic-thomas closed 1 year ago

magic-thomas commented 1 year ago

Hi . First, Really Thanks for great package.

I would like limit the count of thumbnail image.

I am using exportFramesByInterval() for making thumbnails.

I know, I can reduce it by controlling time interval , but that is not what I want.

I don't need thumbnails for whole video.

I need just thumbnails in starting part of video.

How can I limit the thumbnails amount ?

Jandelson commented 1 year ago

Hi magic-thomas You can use as follow method: getFrame FromSeconds combined with a foreach or for. Example:

FFMpeg::open($file)->each([2, 4, 6], function ($ffmpeg, $seconds, $key) { $ffmpeg->getFrameFromSeconds($seconds)->export()->save("thumb_{$key}.png"); });

This resolve your question?

magic-thomas commented 1 year ago

Yes. That is goo solution.. Thanks.