I changed the source code of mplayer (ffmpeg) to extract motion vectors for any compressed video, I downloaded a modified mplayer code that can be used to extract motion vectors here http://www.cs.umd.edu/~bharat/modmplayer.zip
To extract motion vectors you need to do the following if you are using a modified version of mplayer
./mplayer -nosound -fps 200 -vo null -lavdopts vismv = 1 path_of_video_file 2> path_of_output_file.txt
A precompiled executable and some useful files are available in the output folder
source share