For a video, to be added to a web page, I wished to add a cover image derived from the video.
The image was to be shown in the video placement as a teaser for the video.
I wanted to derive an image from the video to be shown as the teaser image.
Perhaps the video editor could be used to select a single frame. But if I could automate the frame grab, maybe from the command line, I would be able to minimise my interaction. I might even be able to automate the conversation for all videos in a directory.
The image doesn’t have to be taken from the first frame, but this may be simplest. The length of a video will vary, but there will always be a first frame.
If I was happy to accept the first frame from the video then I wouldn’t have the distraction of reviewing the video to find the “best” frame. The one which captures the essence of the video.
Although in reality it was most likely going to be the first frame. I didn’t have the inclination to review the video to select a frame.
To be able to spend the minimum of time retrieving an image would be best. Thus taking the first frame would be the best action.
When this is clicked the video is played
The first step was the old friend ffmpeg.
ffmpeg -i myvideo.mp4 -ss 00:00:01.000 -vframes 1 myvideo.png
The parameters used in the above are:
- -i myvideo.mp4: Here the first video myvideo.mp4 is the video from which we’ll create the image.
- -ss 00:00:01.000: the position. In this case the start ill be 1 second in.
- -vframes 1: the number of frames in the output.
- myvideo.png: the name of the saved file. ffmpeg recognises the file reference for what it is and is able to save to the designated file format
The above automation can be extended to do all videos in a directory or maybe added to an all directory video conversion.
I had an existing automation to convert all images of type mp4 in a directory. To this can be added the thumbnail cover image creation.


