[Libav-user] Fetching MacroBlock information

Venkateswaran.S venketeswaran2015 at gmail.com
Fri Apr 12 12:06:31 EEST 2019

Hi all,
    I've a .mp4 file which contain h.264 video and AAC audio. I wants to
extract MacroBlock and motion vector information of each frame while
decoding.  Please find my below Pseudocode.

avformat_open_input(file_name) //opening file
avcodec_open2(pCodecContext, pCodec, NULL) // opening decoder
while (response >= 0) // reading each frame
response = avcodec_receive_frame(pCodecContext, pFrame);
if (response == AVERROR(EAGAIN) || response == AVERROR_EOF || response < 0)
* // extract macroblock of pFrame here*

I have seen in other post mentioned that we can get MB information through
MpegEncContext structure, but i'm confused were and how to instantiate
object of that structure, how the MB data of the structure gets updated for
each frame.?
Ultimately, I wants to compare macroblock from one frame to other frame
using SAD (sum of absolute difference) and trigger alerts if there is any
distortion in macroblock level.
I would really appreciate if anyone help on this ☺.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190412/5a4d273b/attachment.html>

More information about the Libav-user mailing list