(EDIT: sorted this out, thanks everyone, ffmpeg can do everything)

I'm thinking of writing a rust script to create an anki deck given a video file and a subtitle track.

One thing I'm not sure I should do, is how do I get a snapshot from a video file?

Does anyone know a good way to do this?

The script will go through all the timestamps in the provided subtitle file and take screenshots.

#tech #techsupport #SoftwareDev #rust

@sashin Potentially mpv could do this?
@chiraag Good point, I'll look into this!

@sashin @chiraag

#ffmpeg!!

Maybe a combo of these two options?

#ffmpeg extract frames: ffmpeg -i file.mpg -r 1/1 frames%03d.png #ffmpeg trim a video ffmpeg -ss 00:00:00 -to 00:02:00 -i input.mp4 -c copy output.mp4
MPV-screenshots/mpv-screenshots.sh at master · Kcchouette/MPV-screenshots

Take screenshots using MPV software. Contribute to Kcchouette/MPV-screenshots development by creating an account on GitHub.

GitHub
@sashin ffmpeg can most likely do that!
@yukijoou Oh nice! That makes things much more straightforward, will look into this

@sashin just tested based on https://stackoverflow.com/questions/27568254/how-to-extract-1-screenshot-for-a-video-with-ffmpeg-at-a-given-time to grab a frame from a video I had handy:

ffmpeg -ss: 12:34.5 -i foo.mov -frames:v 1 -q:v 2 output.jpg

How to extract 1 screenshot for a video with ffmpeg at a given time?

There are many tutorials and stuff showing how to extract multiple screenshots from a video using ffmpeg. You set -r and you can even start a certain amount in. But I just want 1 screenshot at, s...

Stack Overflow
@sashin
Sorry if you're looking for a way to do it inside rust, which rereading the question you may be. But if not, or if you can script ffmpeg from within rust, I offer this: https://thetechblog.eu/ffmpeg-take-screenshots/
FFmpeg: How to take screenshots – The Tech Blog

@intransitivelie Yeah, this is good. I'll probably be doing it this way, I can just call the command from inside rust, just need to handle failures in a way that makes sense.
@sashin
Glad I could help 🙂 ffmpeg might possibly be powerful enough to do everything you want you do itself, but I'm a novice.