I created a small bash script to extract a single frame from a video file or URL and save it as an image.
When I was creating the first post for this blog, I had uploaded a few videos and noticed that the schema for the back end didn’t have an option to extract a frame to add to the poster attribute for a <video> element. A poster is a placeholder image shown before video playback. Without it, the result of the unplayed video is completely dependent on the browser. Most desktop browsers will grab the first frame by default, but browsers in iOS will not show any image unless a path is explicitly defined.
This pushed me to create a simple tool that I can reach for quickly and easily. I wanted to be able to have some flexibility defining a specific frame or timestamp since the first frame can sometimes be blank. I added a few options like defining width, output directory, and output format (jpg/png/webp), but part of me really wants to turn this into a full CLI that can trim videos, create GIFs, generate images from a range, and other things that I don’t really need right now, but could be useful down the road. If I did build something more robust, I am thinking of re-writing it in Python. Ultimately, I am trying to get better at releasing tools that can solve an immediate problem and not sit on them until they are “complete” and then never actually complete or release them.
The github repo is publicly available if you would like to use it yourself or have any recommendations. I will write a follow-up post if I decide to expand it further.