laravel-ffmpeg
laravel-ffmpeg copied to clipboard
How to set thumbnail to the video?
How can i set a thumbnail to first frame of the video ? most of my videos have black screen intro.

I've got this working in a new branch, but it needs some cleaning up and polishing: https://github.com/protonemedia/laravel-ffmpeg/commit/a2928e9c83eff2b7a6b9535eae7315c06a6f70e5
If you're using HTML, you can also set the thumbnail with the poster attribute:
https://www.w3schools.com/tags/att_video_poster.asp
I've come up with a built-in solution that looks something like this:
FFMpeg::open(['video.mp4', 'thumb.jpg'])
->export()
->addFormatOutputMapping(new CopyFormat, null, ['0'])
->addFormatOutputMapping(new AttachedPicFormat, Media::make('local', 'video_with_thumb.mp4'), ['1'])
->save();
I'll add some additional tests to check if it works with multiple videos and other codecs as well. I still think it can be refactored to something more elegant 🤔
The Class is not found for CopyFormat, AttachedPicFormat and Media.