Capture video frame images (ffmpeg)

As we all know, a video is composed of a set of continuous pictures and audio. Many needs are to use the first picture of the video as the video cover. The most recent project is to take a picture every ten seconds. It still uses ffmpeg. I have to say ffmpeg is a really powerful tool. The only drawback is that it consumes too much cpu. Not much nonsense, just go to the code.

Capture video pictures

Take a picture every ten seconds

ffmpeg -i test.mp4 -q:v 2 -vf "select=between(n\,0\,24000)*not(mod(n\,240))" -vsync 0 test-%d.jpg
  1. ffmpeg is ffmpeg executable file, add the path when using it (free installation version)
  2. -q:v 2 is the video quality, 2 is the highest quality
  3. select=between(n\,0\,24000)*not(mod(n,240)) ,between means starting from frame 0 and ending at frame 24000. If your video is 24 frames per second, then it is 1000 seconds. not(mod(n,240), not identification, take a picture every 240 frames, that is, take a picture in 10 seconds

Take a picture every second

ffmpeg -i test.mp4 -q:v 2 -vf -r 1 -vsync 0 test-%d.jpg
  1. -r means to extract several pictures from the picture every second

Capture the specified number of seconds of video

ffmpeg -i test.mp4 -q:v 2 -ss 1 -vsync 0 test.jpg
  1. -ss represents the number of seconds, can also be set by HH:mm:ss

Guess you like

Origin blog.csdn.net/qq_38306425/article/details/102618797