简体   繁体   English

ffmpeg-X264编码--BGRA到AVFrame(ffmpeg),反之亦然? 对于IOS

[英]ffmpeg-X264 encode --BGRA to AVFrame(ffmpeg) and viceversa? for IOS

Am working Video Processing in IOS(iphone/ipod/ipad) Using Objective c. 使用Objective c在IOS(iphone / ipod / ipad)中进行视频处理。 i am using AVFoundation Framework to Capture Video . 我正在使用AVFoundation Framework捕获视频。 i want to Encode/decode those video frame using ffmpeg-libx264. 我想使用ffmpeg-libx264对这些视频帧进行编码/解码。 i have compiled ffmpeg-x264 lib for ios. 我已经为ios编译了ffmpeg-x264 lib。 i got kCVPixelFormatType_32BGRA from AVFoundation. 我从AVFoundation获得了kCVPixelFormatType_32BGRA。

my problem is 我的问题是
1.How to convert kCVPixelFormatType_32BGRA to AVFrame for enode using avcodec_encode_video? 1.How转换kCVPixelFormatType_32BGRAAVFrame使用avcodec_encode_video的e节点?

2.How to convert AVFrame to kCVPixelFormatType_32BGRA @ decode side from avcodec_decode_video2? 2.如何将avframe从avcodec_decode_video2转换为kCVPixelFormatType_32BGRA @解码端?

Please help me to start above process or give path for working tutorial .Thanks in advance. 请帮助我开始上述过程,或者为工作教程提供路径。谢谢。

If you're trying to use FFMpeg you'll need to use kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange rather than kCVPixelFormatType_32BGRA and then you can shove it into an AVFrame. 如果您尝试使用FFMpeg,则需要使用kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange而不是kCVPixelFormatType_32BGRA,然后可以将其推入AVFrame。 You'll probably also want to convert what you're getting from the iOS camera ( YUVNV12 ) to YUV420P so you can receive it on other devices that aren't iOS. 您可能还希望将从iOS相机( YUVNV12 )获得的内容转换为YUV420P,以便可以在非iOS的其他设备上接收它。 If you are just using iOS devices and that's all you care about, you can skip this side of the color conversion and just pack it into the AVFrame. 如果您仅使用iOS设备,而这就是您所关心的,则可以跳过颜色转换的这一步,只需将其打包到AVFrame中即可。

Since you're already putting it into a YUV format, you can just use CVPixelBufferGetBaseAddressOfPlane(buf,0) and encode that address. 由于您已经将其转换为YUV格式,因此可以只使用CVPixelBufferGetBaseAddressOfPlane(buf,0)并对该地址进行编码。

Once you decode the image, you'll need to change the colors to BGRA from YUV420P . 一旦你解码图像,你需要从YUV420P改变颜色来BGRA。 If you didn't swap the colors properly in the first place before you encoded it, you'll just change YUVNV12 to BGRA. 如果您在编码之前没有正确地交换颜色,则只需将YUVNV12更改为BGRA。

Hope this helps a bit. 希望这个对你有帮助。 You can find the proper color conversion algorithms online. 您可以在线找到合适的颜色转换算法。

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

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