title: Extraction motion vectors from H.264 bitstream
body: <p>I'm looking for an open-source tool/code or some guidance to extract the motion vectors (MVs) of a H.264 encoded bit sequence. I'm already aware that motion vectors can be visualized using ffmpeg with the following command:</p>
  
  <p><code>ffplay -flags2 +export_mvs input.mp4 -vf codecview=mv=pf+bf+bb</code></p>
  
  <p>However, I want to produce a log file where the MVs of P and B frames are listed frame by frame. I checked out the structure of MVs from libavutil/motion_vector.h, but I couldn't find an example which shows how they are extracted and laid over the original sequence by ffplay. I thought that if I can find that out, I could possibly re-arrange the code to extract the MVs to a text file.</p>
  
  <p>I also tried the code given in <a href="https://stackoverflow.com/questions/19993733/motion-vector-extraction-from-encoded-video-file">this answer</a>, but it doesn't seem to work with the newer versions of ffmpeg:</p>
  
  <p>I would appreciate any example codes or hints.</p>