Tag: avcapturemoviefileoutput

如何使用AVCaptureDeviceFormat从iPhone录制timelapsevideo?

我试图通过iPhone录制一个timelapsevideo。 我已经得到它慢动作的工作(通过捕捉最大帧可能),120帧/秒。 现在我正试图颠倒逻辑来捕捉尽可能less的帧,以实现timelapsefunction。 代码stream是这样的: 从AVCaptureDevice的可用设备格式查询所有支持的帧范围。 检查帧速率是否低于或等于所需的20 fps,尺寸等于或大于1920 * 1080。 所有工作正常,除了当我按下logging,我得到"AVCaptureMovieFileOutput – no active/enabled connections"例外。 我只使用提供的帧速率和范围之一,为什么我得到这个exception? 所有的效果为30帧/秒。 #define kTimelapseRequiredFPS = 20 #define kMinRequiredDimensions (1920*1080) – (void)configureCameraForSlowMoRecording:(AVCaptureDevice *)currentCaptureDevice { [_captureSession beginConfiguration]; AVCaptureDeviceFormat *bestFormat = nil; AVFrameRateRange *bestFrameRateRange = nil; for ( AVCaptureDeviceFormat *format in [currentCaptureDevice formats] ) { //NSLog(@"Format: %@", format); CMFormatDescriptionRef videoInfo = [format formatDescription]; double […]

AVCaptureSession addInput问题与ios8

我有一个AVCaptureSession的应用程序与以前的iOS版本正常工作,但后来我试着运行与ios8,应用程序坠毁零星的设备上。 但问题没有解决。 例外进入“[会话addInput:input];” 。 请咨询如何解决。 请validation我的下面的代码,并得到错误在[会话addInput:input]; 打印错误描述:Error Domain = AVFoundationErrorDomain Code = -11852“不能使用后退摄像头”UserInfo = 0x17c076e0 {NSLocalizedDescription =不能使用后退摄像头,AVErrorDeviceKey =,NSLocalizedFailureReason =这个程序没有被授权使用后视镜。 #import "CameraViewController.h" #import "MAImagePickerControllerAdjustViewController.h" #import "PopupViewController.h" #import "MAImagePickerFinalViewController.h" @implementation CameraViewController @synthesize vImagePreview; @synthesize vImage; @synthesize stillImageOutput; @synthesize lFrameCount; @synthesize session; @synthesize device; @synthesize oneOff; @synthesize captureManager = _captureManager; @synthesize flashButton = _flashButton; @synthesize vImage1; @synthesize vImage2; […]

AVCaptureMovieFileOutput后用AVPlayer播放video

我用AVFoundation创build了类似于snapchat的自定义相机。 图片方面的作品:拍照,我显示图片。 现在我正在试着拍一个video并显示video。 我已经捕获了一个成功的video文件,经过testing并与MPMoviePlayer一起工作,但无法在AVPlayer上播放。 – (void)takeVideoAction:(id)sender { NSString *outputPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"output.mp4"]; NSFileManager *manager = [[NSFileManager alloc] init]; if ([manager fileExistsAtPath:outputPath]){ [manager removeItemAtPath:outputPath error:nil]; } [movieFileOutput startRecordingToOutputFileURL:[NSURL fileURLWithPath:outputPath] recordingDelegate:self]; } – (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error{ AVURLAsset *asset = [AVURLAsset URLAssetWithURL:outputFileURL options:nil]; [asset loadValuesAsynchronouslyForKeys:@[@"tracks"] completionHandler:^{ dispatch_async(dispatch_get_main_queue(), ^{ NSError *error = nil; if([asset […]

获取AvCaptureVideoDataOutput可用的实际NSStringVideoCVPixelFormatTypes

我正试图find一个AVFoundation输出接受的格式: self.theOutput=[[AVCaptureVideoDataOutput alloc]init]; if ([self.theSession canAddOutput:self.theOutput]) [self.theSession addOutput:self.theOutput]; 然后,我在之后插入一个断点: po [self.theOutput availableVideoCVPixelFormatTypes] 我得到这个: (NSArray *) $5 = 0x2087ad00 <__NSArrayM 0x2087ad00>( 875704438, 875704422, 1111970369 ) 我如何获得这些格式types的string值? 谢谢

AVCaptureSession和AVCaptureMovieFileOutput帧时间戳

我正在用AVCaptureSession和AVCaptureMovieFileOutput录制电影。 我也在录制加速度数据,并尝试将加速度数据与videoalignment。 我试图找出一种方法来获得开始video文件的时间。 我正在做以下事情: currentDate = [NSDate date]; [output startRecordingToOutputFileURL:fileUrl recordingDelegate:self]; 但是,根据我的testing,在开始调用startRecordingToOutputFileURL之前,video录制开始0.12秒。 我假设这是因为各种video缓冲区已经充满了数据被添加到文件。 反正有没有得到video的第一帧的实际NSDate?

IOS将UIProgressView添加到AVFoundation AVCaptureMovieFileOutput

我正在使用AVCaptureMovieFileOutput来录制video,我想添加一个UIProgressView来表示在video停止录制之前还剩多less时间。 我设置了15秒的最大持续时间: CMTime maxDuration = CMTimeMakeWithSeconds(15, 50); [[self movieFileOutput] setMaxRecordedDuration:maxDuration]; 我似乎无法findAVCaptureMovieFileOutput是否有一个callback,当video正在录制或开始录制。 我的问题是,如何获得录制进度的更新? 或者,如果这不是可用的东西,我怎么能告诉开始录制开始计时器?

NSURL isFileURL总是返回NO

有人可以向我解释为什么下面的代码: NSString* filePathString = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; NSLog(@"%i", [[NSURL URLWithString:filePathString] isFileURL]); NSLog(@"%@", filePathString); 输出: 0 “在/ var /移动/应用/ 28ADFC19-874C-4304-94B5-F6441CAE9FAD /文档” 这意味着这个URL不是一个文件的URL。 显然是这样。 背景: 我正在尝试使用AVCaptureMovieFileOutput将影片录制到文件中,但是我certificate的文件url给出了错误: *由于未捕获exception'NSInvalidArgumentException',原因:'* – [AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] – 无法logging到URL / var / mobile / Applications / 28ADFC19-874C-4304-94B5-F6441CAE9FAD / Documents / media / CrKNjNhe9so2LRnD9iHK .mov,因为它不是一个文件的URL。 就像原来的例子,这看起来像一个文件的URL。 是什么赋予了?

iOS 8 iPad AVCaptureMovieFileOutput在录制13 – 14秒后丢失/丢失/从未获取音轨

我有以下代码适用于iOS 6和7.x. 在iOS 8.1中,我有一个奇怪的问题,如果您捕捉一个会话大约13秒或更长时间,则产生的AVAsset只有1个音轨(video),音轨不在那里。 如果录制的时间较短,则AVAsset有2个音轨(video和audio),如预期的那样。 我有足够的磁盘空间,应用程序有权使用相机和麦克风。 我用最less的代码创build了一个新项目,它重现了这个问题。 任何想法将不胜感激。 #import "ViewController.h" @interface ViewController () @end @implementation ViewController { enum RecordingState { Recording, Stopped }; enum RecordingState recordingState; AVCaptureSession *session; AVCaptureMovieFileOutput *output; AVPlayer *player; AVPlayerLayer *playerLayer; bool audioGranted; } – (void)viewDidLoad { [super viewDidLoad]; [self setupAV]; recordingState = Stopped; } -(void)setupAV { session = [[AVCaptureSession alloc] init]; […]

如何在不使用预设的情况下在iOS上录制video?

在iOS上录制video更简单的方法是设置AVCaptureSession.sessionPreset 。 但是,这并不适合我,因为我想控制像binning,稳定(电影,标准,或无)和ISO参数。 我find了我想要的格式并将其分配给activeFormat ,但是当我尝试开始录制时,出现错误: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] No active/enabled connections' 这是我的初始化代码: let device = AVCaptureDevice.defaultDevice( withDeviceType: .builtInWideAngleCamera, mediaType: AVMediaTypeVideo, position: .back)! let session = AVCaptureSession() session.addInput(try! AVCaptureDeviceInput(device: device)) output = AVCaptureMovieFileOutput() session.addOutput(output) device.setFormatWithHighestIso() session.startRunning() setFormatWithHighestIso()被定义为: extension AVCaptureDevice { var goodVideoFormats: [AVCaptureDeviceFormat] { return (formats as! [AVCaptureDeviceFormat]) […]