This gist shows how to extract motion from a video using the method described by Posy in https://www.youtube.com/watch?v=NSS6yAMZF78
To get the motion from a video by comparing each frame to the one 5 frames later:
./motionextractor.sh input.mp4 5 output.mp4
To compare to the first frame:
./motionextractorfixed.sh input.mp4 1 output.mp4
To get the motion by making grayscale, splitting the RGB channels and separately delaying them by 0, 3 and 6 frames respectively:
./colordelay.sh input.mp4 0 3 6 output.mp4
A version of this is up on replicate at https://replicate.com/chigozienri/posy-motion-extraction, powered by https://github.com/chigozienri/cog-posy-motion-extraction