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

Exporting a thumbnail of a video using resize with getFrameFromSeconds() #504

Closed Luke-Arch closed 11 months ago

Luke-Arch commented 11 months ago

I have this implementation currently, hoping to create a thumbnail from the first frame of video - here I am attempting to resize the video and extract the frame, however it is not currently working. Any advice?

$thumbnail = FFMpeg::fromDisk('local')
            ->open($temporaryVideoPath)
            ->addFilter(function (VideoFilters $filters) {
                $filters->resize(new \FFMpeg\Coordinate\Dimension(150, 150));
            })
            ->getFrameFromSeconds(1)
            ->export()
            ->toDisk('local')
            ->save($thumbnailPath);
Luke-Arch commented 11 months ago

Issue already resolved in another ticket. Used the following method

$thumbnail = FFMpeg::fromDisk('local')
            ->open($temporaryVideoPath)
            ->getFrameFromSeconds(1)
            ->export()
            ->addFilter(function (FrameFilters $filters) {
                $filters->custom('scale=320:180');
            })
            ->toDisk('local')
            ->save($thumbnailPath);