Page 1 of 1

Motion vectors extraction from mp4 file without full decoding

Posted: Thu Mar 29, 2018 1:29 pm
by andyrey
I need a compact c/c++ code for motion vectors extraction from mp4 file without full frame decoding.

I have searched a lot of answers on this kind of question. Many of them point out to code, presuming frame decoding: ... omain?rq=1;; ... ract_mvs.c.

I implemented these codes in my program and saw they decode video frames, and then use frame side data for extracting motion vectors:

Code: Select all

avcodec_receive_frame(video_dec_ctx, frame);//decoding happens here
and then

Code: Select all

sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS);
        if (sd)
            const AVMotionVector *mvs = (const AVMotionVector *)sd->data;

What I badly need: code for extracting motion vectors directly from compressed mp4 file or bitstream with no frame decoding ( no pixel domain restoring). Is it possible?