Answers.Body: <p>ffmpeg with this filterchain does it:</p>
  
  <pre><code>ffmpeg -i input -vf "tblend=average,framestep=2,tblend=average,framestep=2,setpts=0.25*PTS" -r srcfps -{encoding parameters} output
  </code></pre>
  
  <p><code>srcfps</code> should be replaced with your input's framerate.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-15T15:31:12.167Z
Answers.Text: 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"
Answers.UserDisplayName: BarsMonster
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-12T15:53:39.643Z
Answers.Text: so the multiplier to PTS is important to increase rate
Answers.UserDisplayName: genuinefafa
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-22T16:18:21.697Z
Answers.Text: @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.
Answers.UserDisplayName: Michael
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-22T16:23:47.267Z
Answers.Text: @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.
Answers.UserDisplayName: Michael
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-22T16:35:59.553Z
Answers.Text: If I use setpts=1*PTS, it's *still* 0.3fps, but it does produce the expected number of output frames.
Answers.UserDisplayName: Michael
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-25T20:22:35.100Z
Answers.LastActivityDate: 2015-12-25T20:22:35.100Z
Answers.UserDisplayName: Gyan
Answers.Body: <p>I use these commands:</p>
  <p>4x speedup:</p>
  <pre><code>ffmpeg&quot; -r 60 -i &quot;inputfile.mp4&quot;  -vf &quot;tmix=frames=4:weights='1',select='not(mod(n\,4))',setpts=0.25*PTS&quot; -c:v libx265 -an -x265-params crf=25 &quot;outputfile.mp4&quot;
  </code></pre>
  <p>16x speedup:</p>
  <pre><code>ffmpeg&quot; -r 60 -i &quot;inputfile.mp4&quot;  -vf &quot;tmix=frames=16:weights='1',select='not(mod(n\,16))',setpts=0.0625*PTS&quot; -c:v libx265 -an -x265-params crf=25 &quot;outputfile.mp4&quot;
  </code></pre>
  <p>The &quot;-r 60&quot; parameter is used to specify the source file fps.<br />
  The &quot;crf=25&quot; parameter define the encoding quality (lower number = higher quality = higher size)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-02T10:22:20.583Z
Answers.Text: Thanks, that is much more robust and universal solution!
Answers.UserDisplayName: BarsMonster
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-12-28T11:34:57.977Z
Answers.Text: I liked the apparent scalability of this answer, but it turns out this is ridiculously inefficient. If you do a 4× speedup for example, it's generating 4 frames (each averaging the previous 4 frames of the input) and then discarding 3 of them, for each frame of the output. I wanted to do a 60× speedup… you can do the maths. I discovered it would take more than twice as long to render (on an 8-core machine) as the runtime of the original video! Gyan's answer on the other hand, while rather inconvenient for large speedups, scales well because it doesn't do any wasted effort.
Answers.UserDisplayName: mystery
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-01T16:55:10.350Z
Answers.LastActivityDate: 2022-01-01T16:55:10.350Z
Answers.UserDisplayName: Max
Body: <p>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. </p>
  
  <p>Is there a way to do so in ffmpeg?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-05T06:09:38.583Z
Comments.Text: Can you be more specific about how they should be "averaged"? What method do you want to use?
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-05T11:32:39.180Z
Comments.Text: @LordNeckbeard (f1+f2+f3+f4)/4 - simple averaging. So each resulting frame have faint traces of the movement on all sub-frames.
Comments.UserDisplayName: BarsMonster
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-05T15:08:30.380Z
Comments.Text: @BarsMonster I doubt ffmpeg can do this. Have you seen this effect done another way? Do you know what it actually looks like?
Comments.UserDisplayName: Jim Mack
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-05T18:16:14.533Z
Comments.Text: @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 : http://www.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.
Comments.UserDisplayName: BarsMonster
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-05T21:26:46.287Z
Comments.Text: [slowmoVideo](http://slowmovideo.granjow.net/index.html) may be worth a try, but I don't know if it has a cli. The FFmpeg [framerate filter](http://ffmpeg.org/ffmpeg-filters.html#framerate) appears to perform interpolation, but it does not seem to fit your needs.
Comments.UserDisplayName: llogan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-06T20:10:17.673Z
Comments.Text: How about applying the blend filter in 'average' mode where the 2nd input is the same clip with PTS offset by 1 frame. Then use framestep with n=2 to generate result. Then, do the same process with the result. If I have time tomorrow, I'll try this out, but if someone else wants to run with it..
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-08T20:21:22.930Z
Comments.Text: What about extracting the images as separate files, averaging them with imagemagick (I sure it can do this :) ) and then create the video with ffmpeg again?
Comments.UserDisplayName: sebix
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-10-26T21:58:28.440Z
Comments.Text: I'm not sure but maybe with ffmpeg video filters it could be done. It will be a very long filter to write. Actually you should create a filter where you take 4 frames and sum them with opacity of 25% each if i understood correctly what u want to do, then output as single frame and go on until all the movie is done.
Comments.UserDisplayName: user3450548
Tags: <ffmpeg>
Title: 4x resample videoframes using ffmpeg
UserDisplayName: BarsMonster
ThreadText: # 4x resample videoframes using ffmpeg
  
  (Asked by: username_0 on 2015-10-05)
  
  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?
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: Can you be more specific about how they should be "averaged"? What method do you want to use?  
  > **username_0**: @LordNeckbeard (f1+f2+f3+f4)/4 - simple averaging. So each resulting frame have faint traces of the movement on all sub-frames.  
  > **username_2**: @username_0 I doubt ffmpeg can do this. Have you seen this effect done another way? Do you know what it actually looks like?  
  > **username_0**: @username_2 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 : http://www.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.  
  > **username_1**: [slowmoVideo](http://slowmovideo.granjow.net/index.html) may be worth a try, but I don't know if it has a cli. The FFmpeg [framerate filter](http://ffmpeg.org/ffmpeg-filters.html#framerate) appears to perform interpolation, but it does not seem to fit your needs.  
  > **username_3**: How about applying the blend filter in 'average' mode where the 2nd input is the same clip with PTS offset by 1 frame. Then use framestep with n=2 to generate result. Then, do the same process with the result. If I have time tomorrow, I'll try this out, but if someone else wants to run with it..  
  > **username_4**: What about extracting the images as separate files, averaging them with imagemagick (I sure it can do this :) ) and then create the video with ffmpeg again?  
  > **username_5**: I'm not sure but maybe with ffmpeg video filters it could be done. It will be a very long filter to write. Actually you should create a filter where you take 4 frames and sum them with opacity of 25% each if i understood correctly what u want to do, then output as single frame and go on until all the movie is done.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_8 on 2022-01-01. Score: 3 | Accepted answer
  
  I use these commands:
  
  4x speedup:
  
  ```
  ffmpeg" -r 60 -i "inputfile.mp4"  -vf "tmix=frames=4:weights='1',select='not(mod(n\,4))',setpts=0.25*PTS" -c:v libx265 -an -x265-params crf=25 "outputfile.mp4"
  
  ```
  
  16x speedup:
  
  ```
  ffmpeg" -r 60 -i "inputfile.mp4"  -vf "tmix=frames=16:weights='1',select='not(mod(n\,16))',setpts=0.0625*PTS" -c:v libx265 -an -x265-params crf=25 "outputfile.mp4"
  
  ```
  
  The "-r 60" parameter is used to specify the source file fps.  
  The "crf=25" parameter define the encoding quality (lower number = higher quality = higher size)
  
  > **Comments:**
  > **username_0**: Thanks, that is much more robust and universal solution!  
  > **username_9**: I liked the apparent scalability of this answer, but it turns out this is ridiculously inefficient. If you do a 4× speedup for example, it's generating 4 frames (each averaging the previous 4 frames of the input) and then discarding 3 of them, for each frame of the output. I wanted to do a 60× speedup… you can do the maths. I discovered it would take more than twice as long to render (on an 8-core machine) as the runtime of the original video! username_3's answer on the other hand, while rather inconvenient for large speedups, scales well because it doesn't do any wasted effort.  
  
  ---
  
  ### Answer by username_3 on 2015-12-25. Score: 12
  
  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.
  
  > **Comments:**
  > **username_0**: 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"  
  > **username_6**: so the multiplier to PTS is important to increase rate  
  > **username_7**: @username_0 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.  
  > **username_7**: @username_0 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.  
  > **username_7**: If I use setpts=1*PTS, it's *still* 0.3fps, but it does produce the expected number of output frames.  
  
  ---
  
  