简体   繁体   中英

FFMPEG API: decode MPEG to YUV frames and change these frames

I need save all frames from MPEG4 or H.264 video to YUV-frames using C++ library. For example, in .yuv, .y4m or .y format. Then I need read these frames like a digital files and change some samples (Y-value). How can I do it without convert to RGB?

And how store values of AVFrame->data? Where store Y-, U- and V-values?

Thanks and sorry for my English=)

If you use libav* to decode, you will receive the frames in their native colorspace (usually YUV 420) But it is what ever was chosen at encode time. Assuming you are in YUV420 or convert to YUV420 y: AVFrame->data[0] , u: AVFrame->data[1] , v: AVFrame->data[2]

For Y, 1 byte per pixel AVFrame->data[0][(x*AVFrame->linesize[0]) + y] For U and V its 4 pixles per byte (quarter resolution of Y plane). So AVFrame->data[1][(x/2*AVFrame->linesize[1]) + y/2] , AVFrame->data[2][(x/2*AVFrame->linesize[2]) + y/2]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM