Apple文档似乎表明,在将视频录制到文件时,应用程序可以动态更改URL,没有任何问题.但我看到了一个问题.当我尝试这个时,录制代表被调用错误...
这项行动无法完成.(OSStatus错误-12780.)信息字典是:{AVErrorRecordingSuccessfullyFinishedKey = 0; }
("can not"中的时髦单引号来自日志记录[error localizedDescription])
这是代码,基本上是对WWDC10 AVCam示例的调整:
1)开始录音.每隔几秒钟启动计时器以更改输出URL
- (void) startRecording
{
// start the chunk timer
self.chunkTimer = [NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:@selector(chunkTimerFired:)
userInfo:nil
repeats:YES];
AVCaptureConnection *videoConnection = [AVCamCaptureManager connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self movieFileOutput] connections]];
if ([videoConnection isVideoOrientationSupported]) {
[videoConnection setVideoOrientation:[self orientation]];
}
if ([[UIDevice currentDevice] isMultitaskingSupported]) {
[self setBackgroundRecordingID:[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{}]];
}
NSURL *fileUrl = [[ChunkManager sharedInstance] nextURL];
NSLog(@"now recording to %@", [fileUrl absoluteString]);
[[self movieFileOutput] startRecordingToOutputFileURL:fileUrl recordingDelegate:self];
}
Run Code Online (Sandbox Code Playgroud)
2)当计时器触发时,更改输出文件名而不停止记录
- (void)chunkTimerFired:(NSTimer *)aTimer {
if ([[UIDevice currentDevice] …Run Code Online (Sandbox Code Playgroud) 我想捕捉来自设备的背面照相机的视频直接的ProRes编解码器,现在.proRes422和.proRes4444可作为AVVideoCodecType在iOS的11选项.
但我收到一个错误,录音是:
在当前配置下不受支持
在iPhone X和第二代iPad Pro上,尝试使用以下代码捕获视频时:
movieFileOutput.setOutputSettings([AVVideoCodecKey: AVVideoCodecType.proRes422],
for: movieFileOutputConnection!)
Run Code Online (Sandbox Code Playgroud)
如果这种方法是错误的,那么捕获的视频是否可以通过AVCaptureVideoDataOutput并用来编码AVAssetWriter?
我一直在使用AVFoundation对自定义相机进行一些实验,到目前为止一切都很棒.AVCam的例子让我走得很远,我对结果非常满意.
但是,我仍然没有得到的一件事是iOS默认的Camera应用程序如何处理旋转.看起来背景根本不会旋转,但所有叠加控件都会旋转.
这可能不是特定于摄像机的问题,但我怎么能实现这种行为?
TLDR:有一个背景相机层,控件在顶部,如何在不旋转背景层的情况下旋转控件?
Apple的AVCam演示应用程序的演示源代码可在此处找到:https://developer.apple.com/library/content/samplecode/AVCam/Introduction/Intro.html在尝试拍照时崩溃(无论您是否构建了目标-C(或Swift版本)在AVCamCameraViewController/CameraViewController(Swift)线上拍摄照片:
[self.photoOutput capturePhotoWithSettings:photoSettings delegate:photoCaptureDelegate];
Run Code Online (Sandbox Code Playgroud)
或(斯威夫特)
self.photoOutput.capturePhoto(with: photoSettings, delegate: photoCaptureDelegate)
Run Code Online (Sandbox Code Playgroud)
崩溃时的错误消息是:
2016-11-21 17:44:31.590070 AVCam [2178:2303627] *由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'* - [AVCapturePhotoOutput capturePhotoWithSettings:delegate:] flashMode必须设置为supportedFlashModes中存在的值阵"
当我检查闪存模式数组时,我得到了这个:
(lldb)po [self.photoOutput supportedFlashModes] <__ NSSingleObjectArrayI 0x170007c50>(0)
因此,为了添加闪存模式,文档说您必须指定要在AVCapturePhotoSettings对象中支持的模式.我用这行代码完成了这个:
photoSettings.flashMode = AVCaptureFlashModeAuto;
Run Code Online (Sandbox Code Playgroud)
或(斯威夫特)
photoSettings.flashMode = .auto
Run Code Online (Sandbox Code Playgroud)
所以我的预感是,这是一个特别与12.9"iPad Pro有关的错误,我可能需要提交一个雷达,但我想我会问这里,万一有人以前见过它.有什么想法吗?
更新
我也能够复制其他iPad,所以它似乎不仅仅是12.9英寸的iPad Pro.
这不是一个问题,更多的是我在Apple提供的针对iOS4和5相机操作提供的AVCam示例代码周围发现的内容的记录.对我来说问题的症状是我的应用程序在拍摄5-10张照片后启动AVCamViewController时会崩溃.
我通过内存泄漏分析器运行应用程序并且没有明显的泄漏但是在使用Activity Monitor检查时我发现每次启动摄像头时称为mediaserverd的东西增加了17Mb,当它达到~100Mb时,应用程序崩溃了多个低记忆警告.
我在我的iOS应用程序中集成了AVCam.问题是在iPhone 4预览框架不是全屏,它有空边框...
我怎么解决这个问题?
谢谢.
我有一个用AVCapture捕获的视频,我正在尝试使用Swift上传AFNetworking.
码:
let manager = AFHTTPRequestOperationManager()
let url = "http://localhost/test/upload.php"
var fileURL = NSURL.fileURLWithPath(string: ViewControllerVideoPath)
var params = [
"familyId":locationd,
"contentBody" : "Some body content for the test application",
"name" : "the name/title",
"typeOfContent":"photo"
]
manager.POST( url, parameters: params,
constructingBodyWithBlock: { (data: AFMultipartFormData!) in
println("")
var res = data.appendPartWithFileURL(fileURL, name: "fileToUpload", error: nil)
println("was file added properly to the body? \(res)")
},
success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in
println("Yes thies was a success")
},
failure: { (operation: AFHTTPRequestOperation!, error: …Run Code Online (Sandbox Code Playgroud) 我开发 iOS 应用程序,它使用相机。AVCaptureDeviceInput 用于与相机连接。我检查了授权状态为
- (void)checkDeviceAuthorizationStatus
{
NSString *mediaType = AVMediaTypeVideo;
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
if (granted)
{
//Granted access to mediaType
[self setDeviceAuthorized:YES];
}
else
{
//Not granted access to mediaType
dispatch_async(dispatch_get_main_queue(), ^{
[[[UIAlertView alloc] initWithTitle:@"AVCam!"
message:@"AVCam doesn't have permission to use Camera, please change privacy settings"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil] show];
[self setDeviceAuthorized:NO];
});
}
}];
}
Run Code Online (Sandbox Code Playgroud)
当我启动应用程序时,为什么它不询问用户访问相机的权限?因此该应用程序不会出现在设置/隐私/相机中以手动允许访问相机。然后显示此错误"AVCam doesn't have permission to use Camera, please change privacy settings"并且应用程序无法使用相机。
编辑:这意味着未经用户许可,应用程序不得访问相机。不仅是相机,相机胶卷也存在同样的问题。
所有这些事情都是在我在“设置/重置/恢复所有设置”中重置设置后发生的。在此之前,该应用程序运行良好。
我已经实现了AVCaptureSession的概念来录制视频.
-(void)startRecordingWithOrientation:(AVCaptureVideoOrientation)videoOrientation
{
AVCaptureConnection *videoConnection = [AVCamUtilities
connectionWithMediaType:AVMediaTypeVideo
fromConnections:[[self movieFileOutput] connections]];
if ([videoConnection isVideoOrientationSupported])
[videoConnection setVideoOrientation:videoOrientation];
[[self movieFileOutput] startRecordingToOutputFileURL:[self outputFileURL]
recordingDelegate:self];
}
Run Code Online (Sandbox Code Playgroud)
它正确录制视频,但屏幕上没有录制计时器.任何人都知道如何在制作视频时显示计时器.
提前致谢.
avcam ×10
ios ×8
avfoundation ×3
objective-c ×3
swift ×3
iphone ×2
afnetworking ×1
border ×1
fullscreen ×1
ipad ×1
xcode ×1