9

I need to speed up video by a factor of 4x, but do not want to drop the frames and instead average them. I.e. each 4 frames are averaged, and produce 1 output frame. Target frame-rate stays the same, so video is now 4 times faster.

Is there a way to do so in ffmpeg?

8
  • 3
    Can you be more specific about how they should be "averaged"? What method do you want to use?
    – llogan
    Oct 5 '15 at 6:09
  • @LordNeckbeard (f1+f2+f3+f4)/4 - simple averaging. So each resulting frame have faint traces of the movement on all sub-frames. Oct 5 '15 at 11:32
  • @BarsMonster I doubt ffmpeg can do this. Have you seen this effect done another way? Do you know what it actually looks like?
    – Jim Mack
    Oct 5 '15 at 15:08
  • @JimMack I currently did that manually in VirtualDub, they have interpolate filter, with 0.5x interpolation it does correctly average 2 frames. Here is the result : youtube.com/watch?v=8zrws5CGWsI One can see that each frame has movement of 2 subframes, so it is slightly smoother. But doing so in a cmdline would be much faster in the future. Oct 5 '15 at 18:16
  • slowmoVideo may be worth a try, but I don't know if it has a cli. The FFmpeg framerate filter appears to perform interpolation, but it does not seem to fit your needs.
    – llogan
    Oct 5 '15 at 21:26
10

ffmpeg with this filterchain does it:

ffmpeg -i input -vf "tblend=average,framestep=2,tblend=average,framestep=2,setpts=0.25*PTS" -r srcfps -{encoding parameters} output

srcfps should be replaced with your input's framerate.

5
  • 3
    Also tried for x16 using "tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,tblend=average,framestep=2,setpts=0.0625*PTS" Oct 15 '16 at 15:31
  • so the multiplier to PTS is important to increase rate Dec 12 '20 at 15:53
  • @BarsMonster is there a way to use this to combine every frame in the video into a single image output? The docs seem to suggest (since it will use the longest input) that I can just increase the multiplier, but i'm getting silly results before I even get that far, e.g. at 256x with pts at 1/256*PTS I am getting 0.3fps and only 3 frames out of 72,000 when I would expect 281.
    – Michael
    Feb 22 at 16:18
  • @BarsMonster In fact, adjusting PTS doesn't seem to change the reported frame rate, even as high as 0.1PTS I'm still seeing 0.3fps.
    – Michael
    Feb 22 at 16:23
  • If I use setpts=1*PTS, it's still 0.3fps, but it does produce the expected number of output frames.
    – Michael
    Feb 22 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.