FFMPEG - Fast Forwarding a Video 100 times

To create a fast forward video, you can create a filter to change the presentation timestamp (PTS) of each video frame.

Below is a general command - Note - This method drops frame to achieve the speed up. And, I applied the above to a video only file.

ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" output.mkv

where

  • -filter:v mean filter apply to video stream
  • setpts is the set presentation timestamp filter
  • 0.5*PTS means 2X the speed.
Now, to speed thing up in 100x, you can run

ffmpeg -i input.mkv -filter:v "setpts=PTS/100" output.mkv

PTS/100 means speeding the video up by 100x

C:\ffmpeg-2021-11-03-git-08a501946f-full_build\bin>ffmpeg.exe -i "..\..\TimeLapses - Pentas Lack Of Water\pantas_no_audio.mp4" -filter:v "setpts=PTS/100" pantas_ff100x.mp4
ffmpeg version 2021-11-03-git-08a501946f-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 11.2.0 (Rev1, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57.  7.100 / 57.  7.100
  libavcodec     59. 12.100 / 59. 12.100
  libavformat    59.  8.100 / 59.  8.100
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8. 16.101 /  8. 16.101
  libswscale      6.  1.100 /  6.  1.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '..\..\TimeLapses - Pentas Lack Of Water\pantas_no_audio.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.8.100
  Duration: 02:54:08.33, start: 0.010000, bitrate: 13865 kb/s
  Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 13862 kb/s, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 90k tbn (default)
    Metadata:
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 000001fd9e812780] using SAR=1/1
[libx264 @ 000001fd9e812780] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
[libx264 @ 000001fd9e812780] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 000001fd9e812780] 264 - core 164 r3075 66a5bc1 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - 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=12 lookahead_threads=2 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=25 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 'pantas_ff100x.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.8.100
  Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandle
      vendor_id       : [0][0][0][0]
      encoder         : Lavc59.12.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 3137 fps=4.0 q=-1.0 Lsize=   72397kB time=00:01:44.46 bitrate=5677.2kbits/s dup=0 drop=310358 speed=0.134x
video:72359kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.053391%
[libx264 @ 000001fd9e812780] frame I:13    Avg QP:22.04  size:265781
[libx264 @ 000001fd9e812780] frame P:791   Avg QP:24.62  size: 64773
[libx264 @ 000001fd9e812780] frame B:2333  Avg QP:27.59  size:  8317
[libx264 @ 000001fd9e812780] consecutive B-frames:  0.8%  0.1%  0.2% 98.9%
[libx264 @ 000001fd9e812780] mb I  I16..4:  9.2% 61.0% 29.8%
[libx264 @ 000001fd9e812780] mb P  I16..4:  0.9%  1.1%  0.1%  P16..4: 46.6% 16.5% 13.8%  0.0%  0.0%    skip:21.1%
[libx264 @ 000001fd9e812780] mb B  I16..4:  0.1%  0.1%  0.0%  B16..8: 38.4%  3.0%  0.6%  direct: 1.4%  skip:56.4%  L0:48.8% L1:43.1% BI: 8.0%
[libx264 @ 000001fd9e812780] 8x8 transform intra:55.6% inter:74.7%
[libx264 @ 000001fd9e812780] coded y,uvDC,uvAC intra: 41.9% 64.9% 21.8% inter: 14.0% 22.3% 0.8%
[libx264 @ 000001fd9e812780] i16 v,h,dc,p: 42% 21% 18% 19%
[libx264 @ 000001fd9e812780] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 10% 41%  3%  4%  6%  3%  4%  4%
[libx264 @ 000001fd9e812780] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 12%  9%  7%  9% 10%  8%  8%  8%
[libx264 @ 000001fd9e812780] i8c dc,h,v,p: 52% 19% 25%  5%
[libx264 @ 000001fd9e812780] Weighted P-Frames: Y:2.0% UV:1.3%
[libx264 @ 000001fd9e812780] ref P L0: 36.3% 10.3% 39.2% 14.0%  0.2%
[libx264 @ 000001fd9e812780] ref B L0: 65.0% 27.7%  7.3%
[libx264 @ 000001fd9e812780] ref B L1: 86.8% 13.2%
[libx264 @ 000001fd9e812780] kb/s:5668.69



See FFMPEG - Speeding up/slowing down video

Comments

Popular Posts