如何使用 ffmpeg 减慢从 jpg 创建的缩时录像 mp4 的速度

如何使用 ffmpeg 减慢从 jpg 创建的缩时录像 mp4 的速度

我正在 Windows 10 上从一堆 jpg 文件创建延时摄影:

C:\dev\ffmpeg-20180219-acdea9e-win64-static\bin\ffmpeg.exe -r 24 -i Base000%3d.jpg -s hd1080 -vcodec libx264 timelapse.mp4

生成的视频每秒显示的帧数太多:我想让每个图像显示更长时间(例如每秒 4 帧)。

我尝试了一下并将参数降低-r 24-r 4,但它只在整个视频时长中显示一帧:

C:\dev\ffmpeg-20180219-acdea9e-win64-static\bin\ffmpeg.exe -r 4 -i Base000%3d.jpg -s hd1080 -vcodec libx264 timelapse-slow.mp4

ffmpeg version N-90085-gacdea9e7c5 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --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-libmfx --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
  libavutil      56.  7.101 / 56.  7.101
  libavcodec     58. 11.101 / 58. 11.101
  libavformat    58.  9.100 / 58.  9.100
  libavdevice    58.  1.100 / 58.  1.100
  libavfilter     7. 12.100 /  7. 12.100
  libswscale      5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
Input #0, image2, from 'Base000%3d.jpg':
  Duration: 00:00:03.60, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 9600x9600 [SAR 1:1 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[swscaler @ 0000025f0b387900] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0000025f0b330600] using SAR=9/16
[libx264 @ 0000025f0b330600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0000025f0b330600] profile High, level 4.0
[libx264 @ 0000025f0b330600] 264 - core 155 r2901 7d0ff22 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=4 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'timelapse-slow.mp4':
  Metadata:
    encoder         : Lavf58.9.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080 [SAR 9:16 DAR 1:1], q=-1--1, 4 fps, 16384 tbn, 4 tbc
    Metadata:
      encoder         : Lavc58.11.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=   90 fps=3.4 q=-1.0 Lsize=    3936kB time=00:00:21.75 bitrate=1482.6kbits/s speed=0.821x
video:3935kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.049293%
[libx264 @ 0000025f0b330600] frame I:1     Avg QP:16.35  size:185113
[libx264 @ 0000025f0b330600] frame P:27    Avg QP:14.87  size: 86707
[libx264 @ 0000025f0b330600] frame B:62    Avg QP:19.42  size: 24227
[libx264 @ 0000025f0b330600] consecutive B-frames:  2.2% 15.6%  6.7% 75.6%
[libx264 @ 0000025f0b330600] mb I  I16..4:  5.4% 63.8% 30.8%
[libx264 @ 0000025f0b330600] mb P  I16..4:  0.7% 16.7%  2.2%  P16..4: 29.4%  6.1%  6.2%  0.0%  0.0%    skip:38.6%
[libx264 @ 0000025f0b330600] mb B  I16..4:  0.2%  4.0%  0.1%  B16..8: 12.9%  3.1%  1.1%  direct:10.1%  skip:68.5%  L0:39.3% L1:57.3% BI: 3.4%
[libx264 @ 0000025f0b330600] 8x8 transform intra:85.0% inter:61.8%
[libx264 @ 0000025f0b330600] coded y,uvDC,uvAC intra: 90.9% 35.3% 20.4% inter: 20.5% 13.3% 3.7%
[libx264 @ 0000025f0b330600] i16 v,h,dc,p:  5% 10% 14% 71%
[libx264 @ 0000025f0b330600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 16% 35%  5%  7%  6%  9%  5%  7%
[libx264 @ 0000025f0b330600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 26% 15%  6%  9%  6%  8%  4%  7%
[libx264 @ 0000025f0b330600] i8c dc,h,v,p: 75% 15%  9%  1%
[libx264 @ 0000025f0b330600] Weighted P-Frames: Y:44.4% UV:44.4%
[libx264 @ 0000025f0b330600] ref P L0: 60.9%  5.3%  5.4%  2.4% 26.1%
[libx264 @ 0000025f0b330600] ref B L0: 78.0%  8.5% 13.5%
[libx264 @ 0000025f0b330600] ref B L1: 95.9%  4.1%
[libx264 @ 0000025f0b330600] kb/s:1432.27

我怎样才能做到这一点?

相关内容