Create one thumnail:
Method 1: you can specify frame number
ffmpeg -y -i "/home/video/video_7.mp4" -filter:v select="eq(n\,25*12)" -vframes 1 "/home/video/video_7.jpg"
Result:
[root@tutorialspots ~]# ffmpeg -y -i "/home/video/video_7.mp4" -filter:v select="eq(n\,25*12)" -vframes 1 "/home/video/video_7.jpg" ffmpeg version N-92681-g0e833f6 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-28) configuration: --prefix=/root/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --extra-libs=-lpthread --extra-libs=-lm --bindir=/root/bin --enable-gpl --enable-libfdk_aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-openssl --enable-muxer=segment --enable-muxer=stream_segment libavutil 56. 24.101 / 56. 24.101 libavcodec 58. 42.100 / 58. 42.100 libavformat 58. 24.100 / 58. 24.100 libavdevice 58. 6.101 / 58. 6.101 libavfilter 7. 46.101 / 7. 46.101 libswscale 5. 4.100 / 5. 4.100 libswresample 3. 4.100 / 3. 4.100 libpostproc 55. 4.100 / 55. 4.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/video/video_7.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2016-08-20T07:24:15.000000Z Duration: 00:02:04.81, start: 0.000000, bitrate: 1132 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1003 kb/s, 29.98 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default) Metadata: creation_time : 2016-08-20T07:24:15.000000Z handler_name : ISO Media file produced by Google Inc. Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default) Metadata: creation_time : 2016-08-20T07:24:15.000000Z handler_name : ISO Media file produced by Google Inc. Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native)) Press [q] to stop, [?] for help [swscaler @ 0x498c200] deprecated pixel format used, make sure you did set range correctly Output #0, image2, to '/home/video/video_7.jpg': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 encoder : Lavf58.24.100 Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 29.97 fps, 29.97 tbn, 29.97 tbc (default) Metadata: creation_time : 2016-08-20T07:24:15.000000Z handler_name : ISO Media file produced by Google Inc. encoder : Lavc58.42.100 mjpeg Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1 frame= 1 fps=0.0 q=6.6 Lsize=N/A time=00:00:00.03 bitrate=N/A dup=1 drop=1 speed=0.142x video:27kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Method 2: you can specify frame time
ffmpeg -y -i "/home/video/video_7.mp4" -ss 12 -vframes 1 "/home/video/video_7.jpg"
Method 3: you can specify thumnail size
ffmpeg -y -i "/home/video/video_7.mp4" -ss 12 -vframes 1 -s 200x150 "/home/video/video_7.jpg"
Method 4:
ffmpeg -y -i "/home/video/video_7.mp4" -vf thumbnail,scale=300:200 -frames:v 1 "/home/video/video_7.jpg"
Display 4 pictures in an area of 2×2 frames, with 7 pixels between them, and 2 pixels of initial margin
ffmpeg -y -skip_frame nokey -i "/home/video/video_7.mp4" -vf scale=128:72,tile=2x2:nb_frames=4:padding=7:margin=2 -an -vsync 0 -frames:v 1 "/home/video/video_7.jpg"
Create a thumbnail from the middle of a video with FFmpeg
Read more:How to get video duration with ffmpeg
ffmpeg -y -i "/home/video/video_7.mp4" -vframes 1 -ss `ffmpeg -i "/home/video/video_7.mp4" 2>&1 | grep Duration | awk '{print $2}' | tr -d , | awk -F ':' '{print ($3+$2*60+$1*3600)/2}'` "/home/video/video_7.jpg"