YUV视频数据转UIImage

注意

由于声网视频流每秒回调15次。会触发很多的临时变量生成,为了防止内存爆增,为解码代码添加@autoreleasepool.

视频数据接收处

onCaptureVideoFrame 方法为视频回调原始视频数据

 // 获取采集的视频
    virtual bool onCaptureVideoFrame(VideoFrame& videoFrame) override
    {
        std::lock_guard<std::mutex> autolock(m_mtx);
        m_mapVideoTick[0] = get_timestamp();
        if (!mediaDataPlugin) return true;
        @autoreleasepool {
            // ScreenShot
                AgoraVideoRawData *data = getVideoRawDataWithVideoFrame(videoFrame);
                [mediaDataPlugin yuvToUIImageWithVideoRawData:data];
        }
        return true;
    }

其中AgoraVideoRawData是一个YUV的OC对象

@interface AgoraVideoRawData : NSObject

@property (nonatomic, assign) int type;
@property (nonatomic, assign) int width;  //width of video frame
@property (nonatomic, assign) int height;  //height of video frame
@property (nonatomic, assign) int yStride;  //stride of Y data buffer
@property (nonatomic, assign) int uStride;  //stride of U data buffer
@property (nonatomic, assign) int vStride;  //stride of V data buffer
@property (nonatomic, assign) int rotation; // rotation of this frame (0, 90, 180, 270)
@property (nonatomic, assign) int64_t renderTimeMs; // timestamp
@property (nonatomic, assign) char* yBuffer;  //Y da
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值