目标是使用Swift在设备上捕获全屏视频.在下面的代码中,视频捕获似乎全屏发生(录制相机预览时使用全屏),但视频的渲染以不同的分辨率发生.特别是对于5S,看起来捕获发生在320x568但渲染发生在320x480.
如何捕获和呈现全屏视频?
视频捕获代码:
private func initPBJVision() {
// Store PBJVision in var for convenience
let vision = PBJVision.sharedInstance()
// Configure PBJVision
vision.delegate = self
vision.cameraMode = PBJCameraMode.Video
vision.cameraOrientation = PBJCameraOrientation.Portrait
vision.focusMode = PBJFocusMode.ContinuousAutoFocus
vision.outputFormat = PBJOutputFormat.Preset
vision.cameraDevice = PBJCameraDevice.Back
// Let taps start/pause recording
let tapHandler = UITapGestureRecognizer(target: self, action: "doTap:")
view.addGestureRecognizer(tapHandler)
// Log status
print("Configured PBJVision")
}
private func startCameraPreview() {
// Store PBJVision in var for convenience
let vision = PBJVision.sharedInstance()
// Connect PBJVision …Run Code Online (Sandbox Code Playgroud) 我使用苹果公司制作的AVCam作为我的自定义相机视图.老实说,AVCamViewController如果你第一次看到它,那么理解课堂上发生的事情并不简单.
现在我感兴趣他们如何设置捕获图像的帧.我试图找到一些名人或类似的东西,但我没有找到任何.
但是当我实现该解决方案时,我才意识到它只是制作了与我的视图相同大小的实时相机预览图层,但是当应用程序将图像保存- (IBAction)snapStillImage:(id)sender在图库中的方法中时,图像仍然是左右两个条纹.
我的问题是如何删除此条纹或源代码中的哪一行苹果设置这个东西?
另外作为额外的子问题我如何设置类型创建只是照片,因为该应用程序请求我"麦克风设置",我不需要它只需要拍一张照片,就是这样.
来自apple源的此代码将图像保存到照片库.
- (IBAction)snapStillImage:(id)sender
{
dispatch_async([self sessionQueue], ^{
// Update the orientation on the still image output video connection before capturing.
[[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] videoOrientation]];
// Flash set to Auto for Still Capture
[AVCamViewController setFlashMode:AVCaptureFlashModeAuto forDevice:[[self videoDeviceInput] device]];
// Capture a still image.
[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
if (imageDataSampleBuffer)
{
NSData *imageData = [AVCaptureStillImageOutput …Run Code Online (Sandbox Code Playgroud)