13

I'm trying to extract thumbnails from video via ImageMagick. I found some samples from their official site, but it makes GIF, not PNG. I want a solid thumbnail though.

Can it create the same output as with this ffmpeg command?

ffmpeg -ss 600 -i myVideo.mp4 -vframes 1 -s 420x270 Out.bmp
slhck
  • 223,558
  • 70
  • 607
  • 592
Juneyoung Oh
  • 637
  • 4
  • 12
  • 26

2 Answers2

18

You can extract thumbnails from videos with ImageMagick like so (from here - another answer claims that ImageMagick uses ffmpeg 'under the hood', so I don't know if this will actually be any faster than just using ffmpeg):

convert input.mp4[100] thumbnail.png

the [100] tells ImageMagick to take the 100th frame from input.mp4. I've tested it on a H.264 video stream in an MP4 container. Obviously you can use whatever ImageMagick options you want, including deinterlacing as described in your link.


ImageMagick is really for dealing with individual images, though; for video, you should just use ffmpeg. Obviously there is some overlap here, since you're dealing with an individual frame, but I'd say that deinterlacing is more of a video-processing task.

You should use the yadif filter for deinterlacing. You can add it to your existing line thusly:

ffmpeg -ss 600 -i input.mp4 -vframes 1 -s 420x270 -filter:v 'yadif' output.png

when working with filters, I prefer to use the scale filter rather than -s:

ffmpeg -ss 600 -i input.mp4 -vframes 1 -filter:v 'yadif,scale=420:270' output.png
evilsoup
  • 13,097
  • 3
  • 59
  • 80
  • Maybe I'm misunderstanding the question, but the OP specifically asked how to achieve what the `ffmpeg` command does with ImageMagick. No idea if it's possible or not though… – slhck May 25 '13 at 09:26
  • @slhck I interpreted the OP's actual problem as 'getting nice-looking thumbnails from interlaced video', and assumed that they were just trying to use the wrong tool for the job (i.e. get the thumbnail with ffmpeg -> deinterlace with ImageMagick). If anyone were to post a way of doing it with ImageMagick, though, they'd have my upvote. – evilsoup May 25 '13 at 09:36
  • @evilsoup thanks for your answer. I uploaded this question because ffmpeg takes too much time to make thumbnail from video. And I heard from somewhere if I use imagemagick, I can make this faster. Is it true and possible? I've also searched it but there's no way to take thumbnail from video with only imagemagick. Sorry for my poor english. – Juneyoung Oh May 27 '13 at 01:00
  • @JuneyoungOh taking thumbnails with ImageMagick is indeed possible, see the update to my answer. I doubt it'll be any faster, though, since it seems (from my superficial googling) that ImageMagick uses ffmpeg as a back-end for dealing with videos. – evilsoup May 27 '13 at 10:49
  • @evilsoup Oh Thanks.I thought it is impossible. Now I can check which is faster:D many thanks. – Juneyoung Oh May 28 '13 at 01:22
7

ImageMagick shells out to ffmpeg with this command:

ffmpeg -v -1 -vframes %S -i "%i" -vcodec pam -an -f rawvideo -y "%u.pam" 2> "%Z"

So the short answer is "no" (since it does not do it itself).

llogan
  • 57,139
  • 15
  • 118
  • 145
cnd
  • 171
  • 1
  • 1