2013-11-02 13 views
5

Tôi có nguồn cấp dữ liệu video sử dụng trình phát video tùy chỉnh, dựa trên AVPlayer, để phát luồng HLS. Trên thanh điều hướng, có một nút để khởi chạy máy ảnh. Tính đến bản cập nhật iOS 7.0.3, phiên chụp tại gặp vấn đề nghiêm trọng mà nó sẽ bắt đầu, và sau đó ngay lập tức xé bản thân xuống, phát ra một lỗi như vậy:AVCapturePhiên bản bắt đầu và sau đó thất bại ngay lập tức

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}"; 

}} 

Phương pháp của tôi để thiết lập phiên chụp trông giống như này ...

[[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]; 

... và được gọi trong chế độ xemDidAppear of my CameraViewController.

Từ những gì tôi thu thập, có vẻ như khi trình phát video được deallocated trong khi trình bày CameraViewController trên FeedTableViewController, điều gì đó xảy ra gây ra lỗi mediaserverd và mediaremoted. Dưới đây là giao diện điều khiển các bản ghi:

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

Bạn đã giải quyết tình huống này chưa? – Vasanth

+0

@Vasanth có, hãy xem https://github.com/Present-Inc/CameraKit – HighFlyingFantasy

+0

@Vasanth bạn có thể giải thích về giải pháp này không? Tôi đang chạy vào cùng một vấn đề chính xác. Khi tôi thêm AVCaptureAudioDataOutput, phiên máy ảnh của tôi sẽ dừng ngay lập tức. –

Trả lời

0

tôi sẽ cố gắng một vài điều:

tôi sẽ di chuyển dòng này:

captureSession = [[AVCaptureSession alloc] init]; 

tôi sẽ di chuyển nó trên, nơi bạn thêm các nhà quan sát thông báo.

Tôi cũng sẽ thử tạo các thuộc tính lớp đầu ra dữ liệu (âm thanh và video).

Các vấn đề liên quan