<p>Use</p>

<pre><code>ffmpeg
 -ss 00:00:19.7500417 -i "S:\vids\main.mp4"
 -ss 00:00:39.5000834 -i "S:\vids\main.mp4"
 -ss 00:00:59.2501251 -i "S:\vids\main.mp4"
 -filter_complex
 "[0]trim=end_frame=1,scale=-1:480,setpts=N[a];
  [1]trim=end_frame=1,scale=-1:480,setpts=N[b];
  [2]trim=end_frame=1,scale=-1:480,setpts=N[c];
  [a][b][c]vstack=3"
"thumbnails\main.jpg"
</code></pre>

CC BY-SA 4.0
2019-10-04T04:18:12.533Z
Thanks for the answer, but this results in an error "Too many inputs specified for the "vstack" filter". I've included the full output in my question.
Sam
CC BY-SA 4.0
2019-10-04T04:29:04.137Z
Command edited.
Gyan
CC BY-SA 4.0
2019-10-04T05:11:17.073Z
Your solution works great, but takes as much RAM as the video size, which is excessive when the video size itself is 15G or more. Since I only need specific frames, is there any way I can avoid loading the entire video into memory? Perhaps by only using keyframes (or other easy to read approximations)?
Sam
CC BY-SA 4.0
2019-10-04T07:05:57.360Z
It won't load the entire video into memory. Add -benchmark to your cmd and share full log.
Gyan
CC BY-SA 4.0
2019-10-12T02:19:06.160Z
Sorry for the late response - loading the entire video seems to be an issue related to working with remote files. That issue is resolved.
Sam
CC BY-SA 4.0
2019-10-12T02:20:07.553Z
There is however a common issue with your solution that ffmpeg segfaults in some cases like `Stream #0:0: Video: mjpeg, yuvj420p(pc), 480x13550 [SAR 271:272 DAR 3:85], q=2-31, 200 kb/s, 15 fps, 15 tbn, 15 tbc (default)`. I'll create an issue in the bug tracker.
Sam
CC BY-SA 4.0
2019-10-03T08:39:37.620Z
2019-10-04T04:28:50.517Z
2019-10-04T04:28:50.517Z
Gyan
<p>I have a server software that generates video thumbnails using ffmpeg in two steps like this:</p>

<p><strong>Step 1</strong></p>

<pre><code>-ss 00:00:19.7500417 -i "S:\vids\main.mp4"
-ss 00:00:39.5000834 -i "S:\vids\main.mp4"
-ss 00:00:59.2501251 -i "S:\vids\main.mp4"
-y -threads 1 -frames:v 1 -vf "scale=-1:480" -map 0:v:0 "temp\temp0.jpg"
-y -threads 1 -frames:v 1 -vf "scale=-1:480" -map 1:v:0 "temp\temp1.jpg"
-y -threads 1 -frames:v 1 -vf "scale=-1:480" -map 2:v:0 "temp\temp2.jpg"
</code></pre>

<p><strong>Step 2</strong></p>

<pre><code>-i "temp\temp%d.jpg" -y -filter_complex tile=1x3 "thumbnails\main.jpg"
</code></pre>

<p>This works fine when only a few thumbnails are needed, but when 50-100 thumbnails must be written to disk and then tiled separately, overall performance is very slow.</p>

<p>Is there some way I can combine these two commands into a single step?</p>

<p><strong>UPDATE</strong>: @gyan's code results in:</p>

<pre><code>PS C:\Users\Sam\Desktop&gt; .\ffmpeg.exe  -ss 00:00:19.7500417 -i "S:\vids\main.mp4" -ss 00:00:39.5000834 -i "S:\vids\main.mp4" -ss 00:00:59.2501251 -i "S:\vids\main.mp4" -filter_complex "[0]trim=end_frame=1,scale=-1:480,setpts=N[a]; [1]trim=end_frame=1,scale=-1:480,setpts=N[b]; [2]trim=end_frame=1,scale=-1:480,setpts=N[c]; [a][b][c]vstack" "thumbnails\main.jpg"
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'S:\vids\main.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:01:19.95, start: 0.000000, bitrate: 529 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 406x720 [SAR 1:1 DAR 203:360], 424 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'S:\vids\main.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:01:19.95, start: 0.000000, bitrate: 529 kb/s
    Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 406x720 [SAR 1:1 DAR 203:360], 424 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'S:\vids\main.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:01:19.95, start: 0.000000, bitrate: 529 kb/s
    Stream #2:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 406x720 [SAR 1:1 DAR 203:360], 424 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[AVFilterGraph @ 000001dcaf4fef40] Too many inputs specified for the "vstack" filter.
Error initializing complex filters.
Invalid argument
</code></pre>

<ffmpeg><thumbnails>
Capturing and tiling video thumbnails in a single step
Sam
# Capturing and tiling video thumbnails in a single step

(Asked by: username_0 on 2019-10-03)

I have a server software that generates video thumbnails using ffmpeg in two steps like this:
Step 1
-ss 00:00:19.7500417 -i "S:\vids\main.mp4"
-ss 00:00:39.5000834 -i "S:\vids\main.mp4"
-ss 00:00:59.2501251 -i "S:\vids\main.mp4"
-y -threads 1 -frames:v 1 -vf "scale=-1:480" -map 0:v:0 "temp\temp0.jpg"
-y -threads 1 -frames:v 1 -vf "scale=-1:480" -map 1:v:0 "temp\temp1.jpg"
-y -threads 1 -frames:v 1 -vf "scale=-1:480" -map 2:v:0 "temp\temp2.jpg"

Step 2
-i "temp\temp%d.jpg" -y -filter_complex tile=1x3 "thumbnails\main.jpg"

This works fine when only a few thumbnails are needed, but when 50-100 thumbnails must be written to disk and then tiled separately, overall performance is very slow.
Is there some way I can combine these two commands into a single step?
UPDATE: @gyan's code results in:
PS C:\Users\username_0\Desktop> .\ffmpeg.exe  -ss 00:00:19.7500417 -i "S:\vids\main.mp4" -ss 00:00:39.5000834 -i "S:\vids\main.mp4" -ss 00:00:59.2501251 -i "S:\vids\main.mp4" -filter_complex "[0]trim=end_frame=1,scale=-1:480,setpts=N[a]; [1]trim=end_frame=1,scale=-1:480,setpts=N[b]; [2]trim=end_frame=1,scale=-1:480,setpts=N[c]; [a][b][c]vstack" "thumbnails\main.jpg"
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.1.1 (GCC) 20190807
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'S:\vids\main.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:01:19.95, start: 0.000000, bitrate: 529 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 406x720 [SAR 1:1 DAR 203:360], 424 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'S:\vids\main.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:01:19.95, start: 0.000000, bitrate: 529 kb/s
    Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 406x720 [SAR 1:1 DAR 203:360], 424 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'S:\vids\main.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:01:19.95, start: 0.000000, bitrate: 529 kb/s
    Stream #2:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 406x720 [SAR 1:1 DAR 203:360], 424 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[AVFilterGraph @ 000001dcaf4fef40] Too many inputs specified for the "vstack" filter.
Error initializing complex filters.
Invalid argument

**Tags:** ffmpeg, thumbnails


---

## 1 answers

### Answer by username_1 on 2019-10-03. Score: 0 | Accepted answer

Use
ffmpeg
 -ss 00:00:19.7500417 -i "S:\vids\main.mp4"
 -ss 00:00:39.5000834 -i "S:\vids\main.mp4"
 -ss 00:00:59.2501251 -i "S:\vids\main.mp4"
 -filter_complex
 "[0]trim=end_frame=1,scale=-1:480,setpts=N[a];
  [1]trim=end_frame=1,scale=-1:480,setpts=N[b];
  [2]trim=end_frame=1,scale=-1:480,setpts=N[c];
  [a][b][c]vstack=3"
"thumbnails\main.jpg"

> **Comments:**
> **username_0**: Thanks for the answer, but this results in an error "Too many inputs specified for the "vstack" filter". I've included the full output in my question.  
> **username_1**: Command edited.  
> **username_0**: Your solution works great, but takes as much RAM as the video size, which is excessive when the video size itself is 15G or more. Since I only need specific frames, is there any way I can avoid loading the entire video into memory? Perhaps by only using keyframes (or other easy to read approximations)?  
> **username_1**: It won't load the entire video into memory. Add -benchmark to your cmd and share full log.  
> **username_0**: Sorry for the late response - loading the entire video seems to be an issue related to working with remote files. That issue is resolved.  
> **username_0**: There is however a common issue with your solution that ffmpeg segfaults in some cases like `Stream #0:0: Video: mjpeg, yuvj420p(pc), 480x13550 [SAR 271:272 DAR 3:85], q=2-31, 200 kb/s, 15 fps, 15 tbn, 15 tbc (default)`. I'll create an issue in the bug tracker.  

---

