Skip to content

Instantly share code, notes, and snippets.

@salamanders
Last active June 25, 2023 22:45
Show Gist options
  • Save salamanders/3083d4057a3dbfdb7bafc7bb2b88b7e5 to your computer and use it in GitHub Desktop.
Save salamanders/3083d4057a3dbfdb7bafc7bb2b88b7e5 to your computer and use it in GitHub Desktop.
Speed up video 64x with frame blending/averaging using ffmpeg
# Simple 4x speedup, force to 60fps.
/c/bin/ffmpeg/bin/ffmpeg.exe -r 60 -i thefile.mkv -vf "tblend=average,framestep=2,tblend=average,framestep=2,setpts=0.25*PTS" -r 60 -c:v mpeg4 -q:v 1 -an thefile_4x.mp4
# Force input to 60fps. blend 16, and pick 1 of each 16. (do we do extra work for the other 15?) Set PTS to 1/16th of "original". Encode very high quality.
ffmpeg -r 60 -i molt.mp4 \
-vf "crop=in_h:in_h,tmix=frames=16:weights='1',select='not(mod(n\,16))',setpts=0.0625*PTS" \
-c:v libx265 -crf 18 -an molt16.mp4
# I still like the original. Match the "-r NN" to the source frame rate.
# ffmpeg -i FryingPan_deG4NxkouGM.mp4 -vf "tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,setpts=0.015625*PTS" -r 30 -c:v mpeg4 -q:v 1 -an output_64.mp4
# OpenCamera: 15FPS, MPEG4 HVEC, 500kbps was way too low 2Mbps would be better. 1280x720
# ffmpeg -i maker-1.mp4 -i maker-2.mp4 -vf "tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,setpts=0.015625*PTS" -r 15 -c:v mpeg4 -q:v 1 -an output_64.mp4
# to crop: ffmpeg -i joined.mov -vf "crop=in_w-800:in_h-200:400:0,tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,setpts=0.125*PTS" -r 30 -c:v mpeg4 -q:v 1 -an output_8.mp4
# Change goal FPS from 15 (in) to a bit of blur and 60 out: ffmpeg -ss 00:12:03 -i emerge01.mp4 -vf "crop=in_w-400:in_h:400:0,tblend=average,framestep=2,tblend=average,framestep=2,setpts=0.0625*PTS" -r 60 -c:v mpeg4 -q:v 1 -an output_60b.mp4
@salamanders
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment