在iOS 8.1中,我有一个奇怪的问题,如果您捕获约13秒或更长时间的会话,则产生的AVAsset只有1个音轨(视频),音轨不在那里.
如果录制时间较短,AVAsset将按预期的方式播放2个音轨(视频和音频).我有足够的磁盘空间,应用程序有权使用摄像头和麦克风.
我用最小的代码创建了一个新项目,它重现了这个问题.
任何想法将不胜感激.
#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]; [session beginConfiguration]; AVCaptureDevice *vIDeoDevice = nil; for ( AVCaptureDevice *device in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVIDeo] ) { if ( device.position == AVCaptureDevicepositionBack ) { vIDeoDevice = device; break; } } AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio]; if (vIDeoDevice && audioDevice) { AVCaptureDeviceinput *input = [AVCaptureDeviceinput deviceinputWithDevice:vIDeoDevice error:nil]; [session addinput:input]; AVCaptureDeviceinput *audioinput = [AVCaptureDeviceinput deviceinputWithDevice:audioDevice error:nil]; [session addinput:audioinput]; NSURL *recordURL = [self tempurlForRecording]; [[NSfileManager defaultManager] removeItemAtURL:recordURL error:nil]; output= [[AVCaptureMovIEfileOutput alloc] init]; output.maxRecordedDuration = CMTimeMake(45,1); output.maxRecordedfileSize = 1028 * 1028 * 1000; [session addOutput:output]; } [session commitConfiguration];}- (IBAction)recordingbuttonClicked:(ID)sender { if(recordingState == Stopped) { [self startRecording]; } else { [self stopRecording]; }}-(voID)startRecording{ recordingState = Recording; [session startRunning]; [output startRecordingToOutputfileURL:[self tempurlForRecording] recordingDelegate:self];}-(voID)stopRecording{ recordingState = Stopped; [output stopRecording]; [session stopRunning];}- (voID)captureOutput:(AVCapturefileOutput *)captureOutput dIDFinishRecordingToOutputfileAtURL:(NSURL *)outputfileURL fromConnections:(NSArray *)connections error:(NSError *)error{ AVAsset *camerainput = [AVAsset assetWithURL:[self tempurlForRecording]]; //DEPENDING ON HOW LONG RECORDED THIS DIFFERS (<14 SECS - 2 Tracks,>14 SECS - 1 Track) NSLog(@"Number of tracks: %i",camerainput.tracks.count);}-(ID)tempurlForRecording{ NSArray *paths = NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES); Nsstring *documentsDirectoryPath = [paths objectAtIndex:0]; Nsstring *path = @"camerabuffer.mp4"; Nsstring *pathCamerainput =[documentsDirectoryPath stringByAppendingPathComponent: path]; NSURL *urlCamerainput = [NSURL fileURLWithPath:pathCamerainput]; return urlCamerainput;}- (voID)dIDReceiveMemoryWarning { [super dIDReceiveMemoryWarning]; // dispose of any resources that can be recreated.}@end解决方法 这将帮助您解决这个问题.
[MovIEOutput setMovIEFragmentInterval:kCMTimeInvalID];
我认为这是一个错误.文档说明如果录音未成功完成,则不会写入示例表.所以如果成功完成,它将自动被写入.但现在看来似乎没有.
有任何想法吗?
总结以上是内存溢出为你收集整理的iOS 8 iPad AVCaptureMovieFileOutput下降/丢失/从未在录制13 – 14秒后获得音轨全部内容,希望文章能够帮你解决iOS 8 iPad AVCaptureMovieFileOutput下降/丢失/从未在录制13 – 14秒后获得音轨所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)