FFmpeg: Colour animation from macroblock motion-vectors



The animation is created from styling the macroblock motion vectors, as displayed by FFmpeg, rather than by manipulating the actual video content. The blocks of colour are created by stacking 'dilation' filters on the motion-vector layer. Before being dilated, the colouring of the arrows is extracted from the original video by 'colorkey' overlay. Based on an earlier filtergraph experiments.¹

#!/bin/bash 
# Generate stylised animation from video macroblock motion vectors, 
# and present in a side-by-side comparison with original video. 
# version: 2018.03.28.21.08.16 
# source: https://oioiiooixiii.blogspot.com 

cropSize="640:ih:480:0" # Adjust area and dimensions of interest

ffplay \
   -flags2 +export_mvs \
   -i "$1" \
   -vf \
      "
         split [original][vectors];
         [vectors] codecview=mv=pf+bf+bb,
                   crop=$cropSize [vectors];
         [original] crop=$cropSize,
                    split=3 [original][original1][original2];
         [vectors][original2] blend=all_mode=difference128,
                              eq=contrast=7:brightness=-0.3,
                              split [vectors][vectors1];
         [vectors1] colorkey=0xFFFFFF:0.9:0.2 [vectors1];
         [original1][vectors1] overlay,
                               smartblur,
                               dilation,dilation,dilation,dilation,dilation,
                               eq=contrast=1.4:brightness=-0.09 [pixels];
         [vectors][original][pixels] hstack=inputs=3
      "



¹ see also: https://oioiiooixiii.blogspot.com/2016/09/ffmpeg-create-video-composite-of.html
source video: りりあ (LILIA)https://www.youtube.com/watch?v=U1DFzSlNkV8 (used without permission) m(_ _)m