Motion vectors extraction from mp4 file without full decoding

For the developers that use FFmpeg in their software.
Post Reply
User avatar
andyrey
Posts: 2
Joined: Thu Mar 29, 2018 12:57 pm

Motion vectors extraction from mp4 file without full decoding

Post by andyrey » Thu Mar 29, 2018 1:29 pm

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:

https://stackoverflow.com/questions/436 ... omain?rq=1;
https://github.com/vadimkantorov/mpegflow;
https://github.com/FFmpeg/FFmpeg/blob/m ... 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?

Post Reply