简体   繁体   English

FFMPEG API:将MPEG解码为YUV帧并更改这些帧

[英]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. 我需要使用C ++库将所有帧从MPEG4或H.264视频保存到YUV帧。 For example, in .yuv, .y4m or .y format. 例如,.yuv,.y4m或.y格式。 Then I need read these frames like a digital files and change some samples (Y-value). 然后,我需要像读取数字文件一样读取这些帧并更改一些样本(Y值)。 How can I do it without convert to RGB? 不转换为RGB怎么办?

And how store values of AVFrame->data? 以及如何存储AVFrame-> data的值? Where store Y-, U- and V-values? Y,U和V值存储在哪里?

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. 如果使用libav *进行解码,您将在其本机色彩空间(通常为YUV 420)中接收帧,但这是在编码时选择的。 Assuming you are in YUV420 or convert to YUV420 y: AVFrame->data[0] , u: AVFrame->data[1] , v: AVFrame->data[2] 假设您在YUV420中或转换为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). 对于Y,每像素1个字节AVFrame->data[0][(x*AVFrame->linesize[0]) + y]对于U和V,其每个字节4个像素(Y平面的四分之一分辨率)。 So AVFrame->data[1][(x/2*AVFrame->linesize[1]) + y/2] , AVFrame->data[2][(x/2*AVFrame->linesize[2]) + y/2] 因此, AVFrame->data[1][(x/2*AVFrame->linesize[1]) + y/2]AVFrame->data[2][(x/2*AVFrame->linesize[2]) + y/2]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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