ios - 将 UIView 输出为视频流

标签 ios swift opengl-es

是否可以在 Swift 中将 UIView 的内容/上下文作为直接视频流进行流式传输?我并不是真的在寻找“查看屏幕截图”功能,而不是组装视频,这个解决方案是可能的,但帧率远非理想。 更新:也许使用 OpenGL View ?

最佳答案

<强>1。查看截图:您目前的定时功能解决方案是什么?

我相信如果您使用CADisplayLink,您可以获得更好的帧速率。在我的项目中,我可以在 iPhone 7Plus 上以全屏视频 View 获得约 15-20fps 的直播。

<强>2。使用ReplayKit:我认为我不需要以另一种方式重写介绍,因为Apple的文档非常清晰。

Record or stream video from the screen, and audio from the app and microphone.

Using the ReplayKit framework, users can record video from the screen, and audio from the app and microphone. They can then share their recordings with other users through email, messages, and social media. You can build app extensions for live broadcasting your content to sharing services. ReplayKit is incompatible with AVPlayer content.

帧率比 View 截图高很多,但目前仅支持捕获整个屏幕。

因此,如果您想实现仅捕获 View ,可以考虑这样:裁剪输出 CMSampleBufferRef 帧的缓冲区数组。

编辑:如果是将 View 镜像到外部屏幕,那么我们可以使用 ReplayKit 或查看屏幕截图之外的其他解决方案。

关于ios - 将 UIView 输出为视频流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46953896/

相关文章:

objective-c - 如何实现触摸相机图标时在 iOS 锁定屏幕中看到的行为?

ios - GPUImage:GPUImageThreeInputFilter 适用于静止图像输入,但不适用于相机输入

ios - 为什么 Swift 中的 Apple 示例不适合我?

ios - UiPickerview 值在 swift 中显示为问号 ("?"- 但在将其分配给文本框时获得正确的值

swift - 发现 nil NSURL POSt 请求 Swift

ios - 如何发现 OpenGL ES 帧速率是否卡顿 - 没有仪器?

android - 了解Android相机SurfaceTexture和MediaCodec Surface的使用

ios - 通过代码加热 iPhone

ios - MailComposer 在侧边栏中打开

swift - 参数标签 '(itemsCount:)' 不匹配任何可用的重载