19

I need to create a thumbnail from video while uploading it to CDN.

I have been searching for this found this but I am not able to get the screen shot even after following steps.

I am using jwplayer for playing video

Can someone help me to create thumbnail while uploading video using ffmpeg

Community
  • 1
  • 1
Hitesh
  • 3,592
  • 9
  • 36
  • 77

1 Answers1

57

I do not know a way to make a screenshot WHILE uploading, but I do know how to do it after.

The simplest code is:

ffmpeg -i input.mp4 -ss 00:00:01.000 -vframes 1 output.png

Run this script after you have uploaded the file. It should take only a short amount of time if the screenshot is taken in the beginning of the video. (first minute e.g.).

I do not think it is possible to take a screenshot while the file is still being uploaded.

Edit: removed -f image2 as it is guessed correct by ffmpeg

drumkruk
  • 706
  • 7
  • 12
  • 2
    The format is normally guessed from the output file extension, so `-f image2` is not needed here. – llogan Nov 26 '14 at 18:33
  • what is `-f image2` ?? here – Hitesh Nov 27 '14 at 05:52
  • -f is the format of the input/output (normally guessed by ffmpeg) and image2 is the demuxer. See ffmpeg documenation for more info: https://www.ffmpeg.org/ffmpeg-formats.html#Demuxers @LordNeckbeard removed it from the answer – drumkruk Nov 27 '14 at 10:39
  • @hitesh `-f image2` is generally used if the output is a variable. – llogan Nov 27 '14 at 18:52
  • where to give output image file path – Hitesh Nov 28 '14 at 09:37
  • absolute path: foo/bar/output.png – drumkruk Nov 28 '14 at 09:39
  • 2
    If you put -ss before -i, then you won't have to wait for the first minute of frames to go through. However, most decoders can't go to an exact timestamp, so you may end up slightly before your timestamp (eg 00:00:58 instead of 00:01:00). – Suchipi Apr 25 '15 at 09:13
  • What's the `$` sign? – Shayan Dec 13 '19 at 16:32
  • @llogan Do you happen to know what the `$` sign means? I googled linux dollar sign, and I found an example: `lsattr "$(realpath /etc/resolv.conf)"` but I still don't understand why drumkruk is not using parentheses here. – Shayan Feb 11 '20 at 14:45
  • 2
    @Shayan It is just a generic placeholder. To be more clear he could have simply used `input.mp4`. In some languages the `$` indicates a variable. – llogan Feb 11 '20 at 19:08
  • @llogan you are right, it was not needed to have the variable there. – drumkruk Feb 12 '20 at 15:22