3
$\begingroup$

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:

ffplay -flags2 +export_mvs input.mp4 -vf codecview=mv=pf+bf+bb

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.

I would appreciate any example codes or hints.

$\endgroup$
1

2 Answers 2

4
$\begingroup$

I think the following code can help you:
https://github.com/vadimkantorov/mpegflow
The main idea is that you need to decode frames first and query motion frames by calling av_frame_get_side_data function.

$\endgroup$
1
$\begingroup$

Try https://github.com/jishnujayakumar/MV-Tractus. This tool will give you motion vectors in the form of JSON for every frame.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.