S
S
Sergey Sokolov2017-03-10 18:56:57
Video
Sergey Sokolov, 2017-03-10 18:56:57

How to make motion blur effect in ffmpeg?

There are pictures-frames of some animation with a frequency of 60 fps. The output needs a gif with 20 fps.
ffmpeg ... -r 20 or ffmpeg ... -vf fps=20 or the new minterpolate filter all just throw away extra frames.
Is there a way specifically for ffmpeg to generate frames by overlaying one previous and one next with 33% or 25% transparency?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2019-03-18
@sergiks

The updated ffmpeg, starting from version 4.1, has a new video filter tmix - it mixes N neighboring frames.
To create a motion blur effect, you can render the animation at a frame rate N times higher, blend N adjacent frames, and reduce the frame rate back N times by simply throwing out extra frames.

Example script
let WIDTH=640
let HEIGHT=480

let MID=$WIDTH/2

let BUFFER=16
let FRAMERATE=30

let XRATE=$BUFFER\*$FRAMERATE

let DURATION=8
let FPERIOD=$XRATE\*$DURATION

ffmpeg \
  -filter_complex \
  " \
    color=white:${WIDTH}x${HEIGHT}:d=$DURATION:r=$XRATE,format=rgb24[bg];  \
    color=black:8x${HEIGHT}:d=$DURATION:r=$XRATE,format=rgb24[bar];  \
    [bg][bar]overlay=x='$MID + $MID * sin(8 * PI * n / $FPERIOD)':y=0:format=yuv444,format=yuv420p[motion]; \
    [motion]tmix=frames=$BUFFER \
  " \
  -c:v libx264  \
  -r $FRAMERATE  \
  -an  \
  -hide_banner \
  -y  \
  output.mp4

The resulting video .
To make the animation smoother and not suffer from rounding the coordinates to the nearest even integer, the answer from the ffmpeg guru Gyan helped : you need to force full chroma sampling.

A
Axian Ltd., 2017-03-10
@AxianLTD

I watch people use this slowmovideo.granjow.net

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question