• metal2


    metal 看这一篇教程即可

      https://www.jianshu.com/p/625fb38eb411

    -------------------------------------

    (新的--可参考)https://github.com/yinxianxiaozi/Metal_WY

    --------------

    3、重要  设置帧 速率

      MTKView *_view;
        _view.delegate = _render;
        // 设置帧速率 --> 指定时间来调用 drawInMTKView 方法--视图需要渲染时调用 默认60
        _view.preferredFramesPerSecond = 60;

    1、最终视频渲染部分

    https://www.jianshu.com/p/7114536d705a

    ios开发工程/ios音视/LearnMetal-master/Tutorial05-视频渲染-YUV

    2、avframe 转换部分

    /Users/wangt/Desktop/下载的代码/metalios/ffmpeg-player-Metal-YUV

    - (CVPixelBufferRef)createCVPixelBufferFromAVFrame:(AVFrame *)frame {
        if(![self setupCVPixelBufferIfNeed:frame]) return NULL;
        CVPixelBufferRef _pixelBufferRef;
        CVReturn cvRet = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, pixelBufferPoolRef, &_pixelBufferRef);
        if(cvRet != kCVReturnSuccess) {
            NSLog(@"create cv buffer failed: %d", cvRet);
            return NULL;
        }
        CVPixelBufferLockBaseAddress(_pixelBufferRef, 0);
        /// copy y
        size_t yBytesPerRowSize = CVPixelBufferGetBytesPerRowOfPlane(_pixelBufferRef, 0);
        void *yBase = CVPixelBufferGetBaseAddressOfPlane(_pixelBufferRef, 0);
        memcpy(yBase, frame->data[0], yBytesPerRowSize * frame->height);
        /// copy uv
        void *uvBase = CVPixelBufferGetBaseAddressOfPlane(_pixelBufferRef, 1);
        size_t uvBytesPerRowSize = CVPixelBufferGetBytesPerRowOfPlane(_pixelBufferRef, 1);
        memcpy(uvBase, frame->data[1], uvBytesPerRowSize * frame->height / 2);
        CVPixelBufferUnlockBaseAddress(_pixelBufferRef, 0);
        return _pixelBufferRef;
    }
  • 相关阅读:
    CentOS7安装注意
    ES插件安装
    CentOS7命令
    ES安装手册
    五 、redis-cluster java api
    四 、Redis 集群的搭建
    三 redis 的 java api(jedis)
    C#验证码 使用GDI绘制验证码
    云时代架构阅读笔记二——Java性能优化(二)
    【转载】Asp .Net Web Api路由路径问题
  • 原文地址:https://www.cnblogs.com/cnchengv/p/15864350.html
Copyright © 2020-2023  润新知