2013-11-02 2 views
5

AVPlayer를 기반으로하는 사용자 지정 비디오 플레이어를 사용하여 HLS 스트림을 재생하는 비디오 피드가 있습니다. 탐색 모음에는 카메라를 시작하는 버튼이 있습니다. 캡처 세션과 같은 설정에AVCaptureSession이 시작된 다음 즉시 실패합니다.

Capture session error: 


NSConcreteNotification 0x146eae70 {name = AVCaptureSessionRuntimeErrorNotification; object = <AVCaptureSession: 0x15976e70 [AVCaptureSessionPresetHigh]> 
<AVCaptureDeviceInput: 0x145d3ee0 [Back Camera]> -> <AVCaptureVideoDataOutput: 0x159546f0> 
<AVCaptureDeviceInput: 0x1594bd60 [iPhone Microphone]> -> <AVCaptureAudioDataOutput: 0x159823e0> 
<AVCaptureDeviceInput: 0x145d3ee0 [Back Camera]> -> <AVCaptureVideoPreviewLayer: 0x1467b370>; userInfo = { 
AVCaptureSessionErrorKey = "Error Domain=AVFoundationErrorDomain Code=-11819 \"Cannot Complete Action\" UserInfo=0x146f0ec0 {NSLocalizedRecoverySuggestion=Try again later., NSLocalizedDescription=Cannot Complete Action}"; 

}} 

내 방법 : 아이폰 OS 7.0.3 업데이트로, 캡처 세션은 그래서 지금과 같은 오류를 방출, 그것을 시작하고 즉시 자체를 해체 할 심각한 문제가 발생 이 ...

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureSessionDidStartRunning:) name:AVCaptureSessionDidStartRunningNotification object:captureSession]; 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureSessionDidStopRunning:) name:AVCaptureSessionDidStopRunningNotification object:captureSession]; 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureSessionDidFailWithError:) name:AVCaptureSessionRuntimeErrorNotification object:captureSession]; 


discontinuous = NO; 
_recording = NO; 
_paused = NO; 

// Alloc and initialize a capture session 
captureSession = [[AVCaptureSession alloc] init]; 

// Setup and add the video device 
AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 

NSError *videoError = nil; 
_videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&videoError]; 

if (videoError) { 
    ErrorLog(@"%@", [videoError userInfo]); 
}else { 
    if ([captureSession canAddInput:_videoInput]) 
     [captureSession addInput:_videoInput]; 
    else 
     ErrorLog(@"Cannot add video input"); 
} 

// Setup and add the audio device 
AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio]; 

NSError *audioError = nil; 
_audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:&audioError]; 

if (audioError) { 
    ErrorLog(@"%@", [audioError userInfo]); 
}else { 
    if ([captureSession canAddInput:_audioInput]) 
     [captureSession addInput:_audioInput]; 
    else 
     ErrorLog(@"Cannot add audio input"); 
} 

// Alloc and initialize video data output 
AVCaptureVideoDataOutput *videoDataOutput = [[AVCaptureVideoDataOutput alloc] init]; 
captureQueue = dispatch_queue_create("tv.present.captureQueue", DISPATCH_QUEUE_SERIAL); 
[videoDataOutput setSampleBufferDelegate:self queue:captureQueue]; 

// Setup default video capture settings (H.264 video pixel format) 
NSDictionary *videoCaptureSettings = [NSDictionary dictionaryWithObjectsAndKeys: 
             [NSNumber numberWithInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange], kCVPixelBufferPixelFormatTypeKey, 
             nil]; 
[videoDataOutput setVideoSettings:videoCaptureSettings]; 

if ([captureSession canAddOutput:videoDataOutput]) 
    [captureSession addOutput:videoDataOutput]; 
else 
    ErrorLog(@"Cannot add video data output"); 

// Alloc and initialize audio data output 
AVCaptureAudioDataOutput *audioDataOutput = [[AVCaptureAudioDataOutput alloc] init]; 
[audioDataOutput setSampleBufferDelegate:self queue:captureQueue]; 

// Add the output 
if ([captureSession canAddOutput:audioDataOutput]) 
    [captureSession addOutput:audioDataOutput]; 
else 
    ErrorLog(@"Cannot add audio data output"); 

// Setup the video connection 
if ([videoDataOutput connectionWithMediaType:AVMediaTypeVideo]) { 
    videoConnection = [videoDataOutput connectionWithMediaType:AVMediaTypeVideo]; 
    [videoConnection setVideoOrientation:AVCaptureVideoOrientationPortrait]; 


    if ([videoConnection isVideoStabilizationSupported]) 
     [videoConnection setEnablesVideoStabilizationWhenAvailable:YES]; 
} 

// Setup the audio connection 
if ([audioDataOutput connectionWithMediaType:AVMediaTypeAudio]) 
    audioConnection = [audioDataOutput connectionWithMediaType:AVMediaTypeAudio]; 

PLog(@"Will start capture session!"); 
// Start running the capture session 
[captureSession startRunning]; 
PLog(@"Did start capture session!"); 

// Setup the preview layer 
_previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:captureSession]; 
[_previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill]; 

... 내 CameraViewController의 viewDidAppear에서 호출됩니다.

내가 수집 한 것으로부터, FeedTableViewController를 통해 CameraViewController를 표시하면서 비디오 플레이어가 할당 해제되면 mediaserverd 및 mediaremoted 오류가 발생합니다.

나는이 줄을 움직일 것입니다 :

Nov 1 17:28:19 Justin-Makailas-iPhone Present[1320] <Warning>: -[PVideoProcessor setupAndStartCaptureSession] [Line 158] 

Will start capture session! 
Nov 1 17:28:20 Justin-Makailas-iPhone kernel[0] <Debug>: AppleH4CamIn::setPowerStateGated: 1 
Nov 1 17:28:20 Justin-Makailas-iPhone kernel[0] <Debug>: AppleH4CamIn::power_on_hardware 
Nov 1 17:28:20 Justin-Makailas-iPhone voiced[1324] <Warning>: Error (hex)80000008 (int)-2147483640 at /SourceCache/VoiceServices/VoiceServices-225.1/Daemon/VSSpeechServer.m:1286 (destroying TTS instance) 
Nov 1 17:28:29 Justin-Makailas-iPhone Present[1320] <Warning>: -[PVideoProcessor captureSessionDidStartRunning:] [Line 218] 

Capture session did start running 
Nov 1 17:28:29 Justin-Makailas-iPhone kernel[0] <Debug>: 016737.297413 wlan.A[1075] AppleBCMWLANNetManager::checkRealTimeTraffic(): now 16737.297403541 num entries 4 
Nov 1 17:28:29 Justin-Makailas-iPhone kernel[0] <Debug>: 016737.297437 wlan.A[1076] AppleBCMWLANCore::dumpWmeCounters(): per TIDs tx counters: 43722 18715 0 0 0 68128 1584 0, per TIDs rx counters: 30945 256327 1484 0 0 473 104 0 
Nov 1 17:28:29 Justin-Makailas-iPhone kernel[0] <Debug>: 016737.297458 wlan.A[1077] AppleBCMWLANCore::dumpWmeCounters():    AWDL: Tx 0 0 0 0 0 0 0 0,     Rx: 0 0 0 0 0 0 0 0 
Nov 1 17:28:29 Justin-Makailas-iPhone Present[1320] <Warning>: -[PVideoProcessor setupAndStartCaptureSession] [Line 161] 

Did start capture session! 
Nov 1 17:28:30 Justin-Makailas-iPhone ReportCrash[1327] <Notice>: Saved crashreport to /Library/Logs/CrashReporter/stacks+mediaserverd-2013-11-01-172830.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone kernel[0] <Debug>: AppleH4CamInUserClient::clientDied 
Nov 1 17:28:30 Justin-Makailas-iPhone Present[1320] <Warning>: NSConcreteNotification 0x14678540 {name = AVCaptureSessionDidStopRunningNotification; object = <AVCaptureSession: 0x15976e70 [AVCaptureSessionPresetHigh]> 
     <AVCaptureDeviceInput: 0x145d3ee0 [Back Camera]> -> <AVCaptureVideoDataOutput: 0x159546f0> 
     <AVCaptureDeviceInput: 0x1594bd60 [iPhone Microphone]> -> <AVCaptureAudioDataOutput: 0x159823e0> 
     <AVCaptureDeviceInput: 0x145d3ee0 [Back Camera]> -> <AVCaptureVideoPreviewLayer: 0x1467b370>} 
Nov 1 17:28:30 Justin-Makailas-iPhone Present[1320] <Warning>: -[PVideoProcessor captureSessionDidStopRunning:] [Line 214] 

Capture session did stop running 
Nov 1 17:28:30 Justin-Makailas-iPhone Present[1320] <Warning>: -[PVideoProcessor captureSessionDidFailWithError:] [Line 222] 

Capture session error: NSConcreteNotification 0x146eae70 {name = AVCaptureSessionRuntimeErrorNotification; object = <AVCaptureSession: 0x15976e70 [AVCaptureSessionPresetHigh]> 
     <AVCaptureDeviceInput: 0x145d3ee0 [Back Camera]> -> <AVCaptureVideoDataOutput: 0x159546f0> 
     <AVCaptureDeviceInput: 0x1594bd60 [iPhone Microphone]> -> <AVCaptureAudioDataOutput: 0x159823e0> 
     <AVCaptureDeviceInput: 0x145d3ee0 [Back Camera]> -> <AVCaptureVideoPreviewLayer: 0x1467b370>; userInfo = { 
    AVCaptureSessionErrorKey = "Error Domain=AVFoundationErrorDomain Code=-11819 \"Cannot Complete Action\" UserInfo=0x146f0ec0 {NSLocalizedRecoverySuggestion=Try again later., NSLocalizedDescription=Cannot Complete Action}"; 
}} 
Nov 1 17:28:30 Justin-Makailas-iPhone kernel[0] <Debug>: AppleH4CamInUserClient::clientDied 
Nov 1 17:28:30 Justin-Makailas-iPhone kernel[0] <Debug>: AppleH4CamIn::setPowerStateGated: 0 
Nov 1 17:28:30 Justin-Makailas-iPhone kernel[0] <Debug>: AppleH4CamIn::power_off_hardware 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone com.apple.launchd[1] (com.apple.mediaserverd[1308]) <Notice>: (com.apple.mediaserverd) Exited: Killed: 9 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaserverd[1328] <Notice>: 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaserverd[1328] <Notice>: 2013-11-01 05:28:30.579219 PM [AirPlay] HAL plugin initializing 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaserverd[1328] <Notice>: 2013-11-01 05:28:30.581993 PM [AirPlay] HAL plugin initialized 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaserverd[1328] <Notice>: <vad> NOTE:  17:28:30.616 [tid 0x3c6af18c] [304]: Logging defaults: [ General Priority: Note; Trace Priority: Note; Async Priority: Error; Traced Scopes: { } ]. 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:30 Justin-Makailas-iPhone mediaremoted[21] <Error>: Property list invalid for format: 200 (property lists cannot contain NULL) 
Nov 1 17:28:33 Justin-Makailas-iPhone Present[1320] <Warning>: -[PVideoProcessor stopAndTeardownCaptureSession] [Line 169] 

Stop and teardown 
+0

이 문제를 해결 했습니까? – Vasanth

+0

@Vasanth 예, https://github.com/Present-Inc/CameraKit을 확인하십시오. – HighFlyingFantasy

+0

@Vasanth가 솔루션을 자세히 설명해 주시겠습니까? 나는 똑같은 문제를 겪고있다. AVCaptureAudioDataOutput을 추가하면 카메라 세션이 즉시 중지됩니다. –

답변

0

나는 몇 가지 시도 할 것이다 :

captureSession = [[AVCaptureSession alloc] init]; 

난 당신이 통지 관찰자를 추가 할 경우 위의 이동 것입니다 여기에 콘솔 로그입니다.

또한 데이터 출력 (오디오 및 비디오) 클래스 속성을 만들려고합니다.