同时录制视频和播放视频 [英] Record video and play video at the same time

查看:219
本文介绍了同时录制视频和播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想播放视频(带声音)并同时录制前置摄像头的视频。相机的取景器应显示为屏幕右下角的小画中画,同时电影在其后面全屏播放。这可能吗?是否可以将相应的类层叠在一起?

I want to play a video (with sound) and record video from the front-facing camera at the same time. The view finder for the camera should appear as a small "picture-in-picture" in the bottom right hand corner of the screen while the movie plays full screen behind it. Is this possible? Is layering the appropriate classes on top of each other possible?

推荐答案

查看 AVFoundation 框架,用于很多iOS中的音频和视频编程。

Check out the AVFoundation framework, which is used for much of the audio and video programming in iOS.

在您的情况下,您可以使用 AVPlayer AVPlayerLayer 播放您的电影,以及 AVCaptureSession AVCaptureVideoPreviewLayer ,以及 AVCaptureMovieFileOutput 要记录。

In your case you could use an AVPlayer and AVPlayerLayer to play your movie, and an AVCaptureSession, an AVCaptureVideoPreviewLayer, and an AVCaptureMovieFileOutput to record.

如果您熟悉核心动画,您可以设置界限并将子图层添加到 AVPlayerLayer AVCaptureVideoPreviewLayer 实现所需的界面布局out。

If you are familiar with Core Animation, you can set the bounds and add sublayers to AVPlayerLayer and AVCaptureVideoPreviewLayer to achieve you desired interface layout.

这些类有很好的文档记录, AVFoundation编程指南 清楚地解释了他们的互动。

These classes are very well documented, and the AVFoundation Programming Guide clearly explains their interaction.

如有任何问题,请随时发表评论。

Feel free to comment with any questions.

这篇关于同时录制视频和播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆