Skip to content

Instantly share code, notes, and snippets.

@jhallard
Created June 22, 2018 22:56
Show Gist options
  • Save jhallard/09b310af5ceb460188452e8f304cd1b5 to your computer and use it in GitHub Desktop.
Save jhallard/09b310af5ceb460188452e8f304cd1b5 to your computer and use it in GitHub Desktop.
Visualize the motion vectors in an h264 encoded video using ffmpeg and vlc (works on OSX)
vis_motion_vectors ()
{
if [ "$#" -lt 1 ]; then
echo "Need an input file";
return 1;
else
ffmpeg -y -loglevel error -flags2 +export_mvs -i "$1" -vf codecview=mv=pf+bf+bb /tmp/motion_vectors.mp4;
case "$(uname -s)" in
Linux*) vlc /tmp/motion_vectors.mp4;;
Darwin*) open /tmp/motion_vectors.mp4 -a vlc;;
*) echo "unknown platform, unable to run. open /tmp/motion_vectors.mp4 in VLC manually";;
esac
fi
}
# use like
# $ use_motion_vectors /tmp/video.mp4
# it will open VLC with a new video that has the motion vectors encoded over the video
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment