Create thumbs for a lot of MP4 videos with ffmpeg

1

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.

momo

Posted 2017-10-29T16:57:30.367

Reputation: 11

Answers

1

for i in '' `seq 1 1000`;do
    ffmpeg -i test${i}.mp4 -vf  "thumbnail" -frames:v 1 test${i}-thumb.jpg
done

Ipor Sircer

Posted 2017-10-29T16:57:30.367

Reputation: 3 578

Better: for i in {1..1000} – Bash has range expansion: http://wiki.bash-hackers.org/syntax/expansion/brace

– slhck – 2017-10-29T17:29:20.490

I'm always using ksh. – Ipor Sircer – 2017-10-29T17:39:31.753

1Why use a sequence? for f *.mp4;do ffmpeg -i $f -vf "thumbnail" -frames:v 1 $(basename $f .mp4)-thumb.jpg; done – xenoid – 2017-10-29T17:44:19.337

In a deleted answer (since he cannot comment), the OP is asking how to capture thumbnails from a few seconds in (e.g. 10) or from the middle of the video. Perhaps you could amend your answer. – slhck – 2017-10-29T20:59:58.630

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. https://ffmpeg.org/ffmpeg-filters.html#thumbnail

– Ipor Sircer – 2017-10-29T21:22:42.097

1We'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 – 2017-10-29T21:31:30.873