ffmpeg使用scale + pad + vstack过滤器创建的幻灯片视频仅包含一个图像

时间:2017-06-27 09:18:20

标签: ffmpeg

$ ls -1 *.jpg
1.jpg # could be any size, here is 210×315
2.jpg # could be any size, here is 480x480
3.jpg # could be any size, here is 480x480

$ ls -1 *.png
bg.png # 480x160

$ ffmpeg -y -r 0.5 -pattern_type glob -i '*.jpg' -i bg.png -filter_complex 'scale=iw*min(480/iw\,480/ih):ih*min(480/iw\,480/ih),pad=480:480:(480-iw*min(480/iw\,480/ih))/2:(480-ih*min(480/iw\,480/ih))/2,vstack' -vsync vfr -c:v libx264 -pix_fmt yuv420p out.mp4

...

$ ffprobe out.mp4
ffprobe version 3.3.2 Copyright (c) 2007-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libfreetype --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --disable-lzma --enable-vda
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
  Duration: 00:00:02.00, start: 0.000000, bitrate: 152 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 480x640 [SAR 1:1 DAR 3:4], 149 kb/s, 0.50 fps, 0.50 tbr, 16384 tbn, 1 tbc (default)
    Metadata:
      handler_name    : VideoHandler

视频大小480x640是正确的,但它只持续2秒,只包含第一张图片1.jpg,请告诉我如何解决这个问题?

-------

0 个答案:

没有答案
相关问题