Get thumbnail from video

Hi everyone! I need to get a frame of a video to use as a poster in a html video tag so when the site is opened on browsers that don’t support autoplay something is displayed. Is possible to do this with kirby?

Thanks in advance!

Check out this if you want a way to extract a thumbnail from a video:

For YouTube videos, you can also define thumbnails that are then used when you include a Youtube video on your page, I think.

Regarding Autoplay:

I had to do the exact same thing last week for some videos. Since they won’t change very often, I didn’t bother to write a plugin. This is the command I ran on the CLI to extract the first frame as an image:

ffmpeg -i video.mp4 -vf "select=eq(n\,0)" -q:v 1 poster.jpg

You could create a panel.file.upload hook that runs that command with the PHP exec function if ffmpeg is installed on your server.

1 Like

Thank you both for the information.
I think the panel.file.upload hook can work for me, I will investigate how to do it.
Thank you again!

I usually do it with VLC. Just pause the video on the on the frame you want and chose video > snapshot from the main menu.

A nice way to do it from inside Kirby would be great tho.

First draft Kirby Video Plugin with Image preview.

@schnti: Wouldn’t it make sense to get the video thumbnail only once, save it on the server and then load it from there? Currently, there is still a connection to Youtube servers before the user clicks on play.

The best way to ensure privacy is to self-host videos, then the user can even watch the video without sending data to Google.

As long your blessed with hosting that has lots of bandwidth and storage space :slight_smile: I find the best balance if your not is to pay for Vimeo because you can lock it down a fair bit.

@guidoferreyra and @schnti :
If you run Windows on your computer (or webserver) you can use the script “do_ffmpeg.bat”.
Adapt it to your needs.

Yes, that might be an issue for video heavy sites, but not for the occasional video. But self-hosting certainly requires more effort to provide different video formats etc. And after all, providing as much privacy as possible is certainly better than providing no privacy at all.

However, the plugin doesn’t really solve the TO’s problem which was about auto-generating a thumbnail from a video, anyway.

The plugin is downloading the thumbnail only once and saves it to $tag->page()->root(). PHP (Webserver, no JavaScript) is downloading the thumbnail at the first time the page is rendered, so no IP address or other data from the visitor is send to google.

Currently I have the problem that the download only works for the second time. Maybe you have an idea?

@schnti Oh sorry, I thought I’d still seen a connection to YouTube servers in the connection tab, but yes, you check if the file already exists.

Hi there, is there any news about auto creating a thumb from uploaded video in mp4 format from KIrby 3?

@nicolasbulb Are you talking about video uploaded to your own server or videos on YouTube etc.? this is nothing Kirby does automatically, anyway and would require a plugin.

Hi, I’m talking about video uploaded to your own server. I’ve seen this post as well: Video (mp4) preview in panel
But I’m on Kirby 3.2.4 not 2, does that makes a difference?

The same answer as above is still valid: Use ffmpeg-php, e.g. in a file.create:afterhook.