FFMPEG-无效的过滤器索引

FFMPEG-无效的过滤器索引

我正在尝试使用 FFMPEG 创建平铺视频,示例如下:

call ffmpeg.bat ^
  -y ^
  -i "video 1.mp4" -i "video 2.mp4" "video 3.mp4" -i "video 4.mp4" ^
  -filter_complex "[0:v][1:v][2:v][3:v]xstack=inputs=4:layout=0_0|w0_0|0_h0|w0_h0[v]" ^
  -map "[v]" ^
  tiled2x2.mp4

我收到错误:

Invalid file index 3 in filtergraph description [0:v][1:v][2:v][3:v]xstack=inputs=4:layout=0_0|w0_0|0_h0|w0_h0[v].

我哪里做错了?

完整命令输出:

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  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 'video 1.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp41isom
    creation_time   : 2020-04-24T21:11:58.000000Z
  Duration: 00:00:19.03, start: 0.000000, bitrate: 8092 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], 7894 kb/s, 30.01 fps, 30 tbr, 30k tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2020-04-24T21:11:58.000000Z
      handler_name    : VideoHandler
      encoder         : AVC Coding
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 191 kb/s (default)
    Metadata:
      creation_time   : 2020-04-24T21:11:58.000000Z
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'video 2.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp41isom
    creation_time   : 2020-04-24T21:12:21.000000Z
  Duration: 00:00:12.87, start: 0.000000, bitrate: 8393 kb/s
    Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], 8196 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2020-04-24T21:12:21.000000Z
      handler_name    : VideoHandler
      encoder         : AVC Coding
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 194 kb/s (default)
    Metadata:
      creation_time   : 2020-04-24T21:12:21.000000Z
      handler_name    : SoundHandler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'video 4.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp41isom
    creation_time   : 2020-04-24T21:13:05.000000Z
  Duration: 00:00:15.48, start: 0.000000, bitrate: 8100 kb/s
    Stream #2:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], 7907 kb/s, 29.13 fps, 30 tbr, 30k tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2020-04-24T21:13:05.000000Z
      handler_name    : VideoHandler
      encoder         : AVC Coding
    Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 186 kb/s (default)
    Metadata:
      creation_time   : 2020-04-24T21:13:05.000000Z
      handler_name    : SoundHandler
Invalid file index 3 in filtergraph description [0:v][1:v][2:v][3:v]xstack=inputs=4:layout=0_0|w0_0|0_h0|w0_h0[v].

答案1

-i之前缺少一个"video 3.mp4"。请尝试:

call ffmpeg.bat ^
  -y ^
  -i "video 1.mp4" -i "video 2.mp4" -i "video 3.mp4" -i "video 4.mp4" ^
  -filter_complex "[0:v][1:v][2:v][3:v]xstack=inputs=4:layout=0_0|w0_0|0_h0|w0_h0[v]" ^
  -map "[v]" ^
  tiled2x2.mp4

相关内容