I have a folder with 1000 MP4 videos and I would like to generate thumbnails for the videos.

Currently the videos are named like this:

test.mp4 test1.mp4 test2.mp4 test3.mp4

I would like the thumbnails images to be named like this:

test-thumb.jpg test1-thumb.jpg test2-thumb.jpg test3-thumb.jpg

Would you please help me with the right command to achieve that? I'm using CentOS 7.

for i in '' `seq 1 1000`;do
    ffmpeg -i test${i}.mp4 -vf  "thumbnail" -frames:v 1 test${i}-thumb.jpg
  • Better: for i in {1..1000} – Bash has range expansion: wiki.bash-hackers.org/syntax/expansion/brace – slhck Oct 29 '17 at 17:29
  • I'm always using ksh. – Ipor Sircer Oct 29 '17 at 17:39
  • 1
    Why use a sequence? for f *.mp4;do ffmpeg -i $f -vf "thumbnail" -frames:v 1 $(basename $f .mp4)-thumb.jpg; done – xenoid Oct 29 '17 at 17:44
  • 1
    No need to amend. Look, I used a video filter called thumbnail. It tries to choose the most representative frame from the first 100. ffmpeg.org/ffmpeg-filters.html#thumbnail – Ipor Sircer Oct 29 '17 at 21:22
  • 1
    We'd like answers to be more than just a few lines of code. If you could add a little more explanation on how to use the filter or how else to get thumbnails from a different part of the movie, that'd be better. – slhck Oct 29 '17 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.