ReplayKit error: Code=-5833 "Failed to start due to audio/video capture failure"

Getting this error Error Domain=com.apple.ReplayKit.RPRecordingErrorDomain Code=-5833 "Failed to start due to audio/video capture failure" UserInfo={NSLocalizedDescription=Failed to start due to audio/video capture failure}. This occurs when calling startCaptureWithHandler a second time after having successfully completed a screen capture session (startCaptureWithHandler and stopCaptureWithHandler both completed successfully and sample buffers were successfully delivered in between).


replayd output between stopping the previous capture and the failed startCaptureWIthHandler is below:


default 11:55:24.833994 -0800 replayd RPConnectionManager: stopRecordingWithHandler

default 11:55:24.834098 -0800 replayd RPRecordingManager: stopRecordingWithHandler:

default 11:55:24.834186 -0800 replayd RPRecordingManager: stopRecordingWithStartTimeOffset:endTimeOffset:handler:

default 11:55:24.834286 -0800 replayd RPRecordingSession: finishSessionWithHandler

default 11:55:24.834384 -0800 replayd RPRecordingSession: stop

default 11:55:24.834927 -0800 replayd RPRecordingSession: stopAllCapture

default 11:55:24.834995 -0800 replayd RPScreenCaptureManagerIOS: stop capture with FigCaptureController: 0x1089122c0

default 11:55:24.835054 -0800 replayd RPClientProxy:updateScreenRecordingStateWithCurrentState:

default 11:55:24.835193 -0800 replayd RPRecordingManager:resetStatesForSession:

default 11:55:24.835253 -0800 replayd RPConnectionManager: stopRecordingWithHandler completed

default 11:55:24.835340 -0800 replayd startLogging: Client starts logging...

default 11:55:24.844330 -0800 replayd RPCaptureManager: stopDeviceCaptureSessionWithFinishHandler

default 11:55:24.855789 -0800 replayd <private>

default 11:55:24.856105 -0800 replayd RPAppAudioCaptureManager:stopAudioCapture: Audio Queue successfully stopped

default 11:55:24.856157 -0800 replayd sendOneMessageWithSessionInfo: XPC connection invalidated

default 11:55:24.874763 -0800 replayd RPAppAudioCaptureManager: Audio Queue has been disposed

default 11:55:56.177716 -0800 replayd RPConnectionManager: startRecordingWindowLayerContextIDs

default 11:55:56.177767 -0800 replayd RPRecordingManager:startRecordingWindowLayerContextID:windowSize:microphoneEnabled:streaming:withHandler:

default 11:55:56.178733 -0800 replayd RPRecordingManager:checkRecordingRequirementsForSession:

default 11:55:56.182929 -0800 replayd RPRecordingManager:showAcknowledgementAlert

default 11:55:56.183025 -0800 replayd -[RPRecordingManager showAcknowledgementAlertForSession:isBroadcast:microphone:camera:] Recording session is exempt, not showing the acknowledgement alert.

default 11:55:56.183074 -0800 replayd RPRecordingManager:checkRecordingRequirementsForSession: No Error Found!

default 11:55:56.183176 -0800 replayd RPConnectionManager: startRecordingWindowLayerContextIDs completed

default 11:55:56.183309 -0800 replayd broadcast disabled

default 11:55:56.183399 -0800 replayd RPRecordingSession: disableBroadcast

default 11:55:56.183486 -0800 replayd starting...

default 11:55:56.183661 -0800 replayd RPRecordingSession: startSession

default 11:55:56.184081 -0800 replayd RPMovieWriter: startWritingHandler

default 11:55:56.184146 -0800 replayd RPMovieWriter: setUpAssetWriterWithHandler

default 11:55:56.184201 -0800 replayd RPMovieWriter: Updating the AVAssetWriter path from /private/var/mobile/Library/ReplayKit/ProjectXRMobile_01-02-2020 11-55-56.mp4 to /private/var/mobile/Library/ReplayKit/ProjectXRMobile_01-02-2020 11-55-56_1.mp4 with start count of 1

default 11:55:56.184378 -0800 replayd RPMovieWriter: bit rate set to 19408078

default 11:55:56.192336 -0800 replayd RPRecordingSession: startWritingHandler: returned

default 11:55:56.192394 -0800 replayd RPRecordingSession: startOrResumeCaptureSessionWithHandler:

default 11:55:56.192514 -0800 replayd RPScreenCaptureManagerIOS: replay mode

default 11:55:56.192931 -0800 replayd RPScreenCaptureManagerIOS: starting capture with FigCaptureController: 0x1089122c0

default 11:55:56.194286 -0800 mediaserverd AudioSessionServerImp.cpp:1254:SetAudioCategory: { "action":"set_category", "session":{"ID":"0x44e9107","PID":16625,"name":"replayd"}, "details":{"key":"AudioCategory","value":"PlayAndRecord"} }

default 11:55:56.195102 -0800 mediaserverd AudioSessionServerImp.cpp:2874:AudioSessionSetProperty: { "action":"set_property", "session":{"ID":"0x44e9107","PID":16625,"name":"replayd"}, "details":{"key":"EnableBluetoothRecording","value":true} }

default 11:55:56.196915 -0800 mediaserverd AudioToolboxServers.mm:516:AudioToolboxServerHandleInterruptionWithID: ================= -> RoutingBehaviorChanged process 'sid:0x44e9107, replayd(16625), 'prim'' =================

default 11:55:56.197453 -0800 mediaserverd AudioToolboxServers.mm:525:AudioToolboxServerHandleInterruptionWithID: ================= <- RoutingBehaviorChanged process 'sid:0x44e9107, replayd(16625), 'prim'' =================

default 11:55:56.197617 -0800 mediaserverd AudioSessionServerImp.cpp:2874:AudioSessionSetProperty: { "action":"set_property", "session":{"ID":"0x44e9107","PID":16625,"name":"replayd"}, "details":{"key":"DefaultBuiltInRoute","value":null} }

default 11:55:56.197903 -0800 mediaserverd AudioSessionServerImp.cpp:2874:AudioSessionSetProperty: { "action":"set_property", "session":{"ID":"0x44e9107","PID":16625,"name":"replayd"}, "details":{"key":"InterruptionStyle","value":"Mix with others"} }

default 11:55:56.198209 -0800 mediaserverd AudioToolboxServers.mm:516:AudioToolboxServerHandleInterruptionWithID: ================= -> RoutingBehaviorChanged process 'sid:0x44e9107, replayd(16625), 'prim'' =================

default 11:55:56.198387 -0800 mediaserverd AudioToolboxServers.mm:525:AudioToolboxServerHandleInterruptionWithID: ================= <- RoutingBehaviorChanged process 'sid:0x44e9107, replayd(16625), 'prim'' =================

default 11:55:56.198583 -0800 mediaserverd AudioToolboxServers.mm:516:AudioToolboxServerHandleInterruptionWithID: ================= -> RoutingBehaviorChanged process 'sid:0x44e9107, replayd(16625), 'prim'' =================

default 11:55:56.198667 -0800 mediaserverd AudioToolboxServers.mm:525:AudioToolboxServerHandleInterruptionWithID: ================= <- RoutingBehaviorChanged process 'sid:0x44e9107, replayd(16625), 'prim'' =================

default 11:55:56.198755 -0800 mediaserverd AudioSessionServerImp.cpp:2874:AudioSessionSetProperty: { "action":"set_property", "session":{"ID":"0x44e9107","PID":16625,"name":"replayd"}, "details":{"key":"WantsToPauseSpokenAudio","value":false} }

default 11:55:56.199415 -0800 mediaserverd AudioSessionServerImp.cpp:2874:AudioSessionSetProperty: { "action":"set_property", "session":{"ID":"0x44e9107","PID":16625,"name":"replayd"}, "details":{"key":"AllowedRouteTypes","value":[]} }

default 11:55:56.199555 -0800 mediaserverd AudioToolboxServers.mm:516:AudioToolboxServerHandleInterruptionWithID: ================= -> RoutingBehaviorChanged process 'sid:0x44e9107, replayd(16625), 'prim'' =================

default 11:55:56.199660 -0800 mediaserverd AudioToolboxServers.mm:525:AudioToolboxServerHandleInterruptionWithID: ================= <- RoutingBehaviorChanged process 'sid:0x44e9107, replayd(16625), 'prim'' =================

default 11:55:56.202346 -0800 replayd RPAppAudioCaptureManager: startAudioCapture: Created Audio Queue Input

default 11:55:56.202734 -0800 replayd RPAppAudioCaptureManager: startAudioCapture: Successfully set Audio Queue to PID

default 11:55:56.260242 -0800 replayd RPScreenCaptureManagerIOS: Screen sampled at w:886 h:1920

default 11:55:56.309196 -0800 replayd RPScreenCaptureManagerIOS: Screen sampled at w:886 h:1920

default 11:55:56.327891 -0800 replayd RPScreenCaptureManagerIOS: Screen sampled at w:886 h:1920

default 11:55:56.336548 -0800 replayd RPAppAudioCaptureManager: startAudioCapture: Successfully started Audio Queue Recording

default 11:55:56.336597 -0800 replayd RPAppAudioCaptureManager: isRunningListenerCallback with isRunning 0

default 11:55:56.350728 -0800 replayd RPScreenCaptureManagerIOS: Screen sampled at w:886 h:1920

default 11:55:56.362608 -0800 replayd recorder is not running, ignoring audio data

default 11:55:56.371407 -0800 replayd RPScreenCaptureManagerIOS: Screen sampled at w:886 h:1920

default 11:55:56.376151 -0800 replayd recorder is not running, ignoring audio data

default 11:55:56.397305 -0800 replayd recorder is not running, ignoring audio data

default 11:55:56.400385 -0800 replayd RPScreenCaptureManagerIOS: Screen sampled at w:886 h:1920

default 11:55:56.419258 -0800 replayd recorder is not running, ignoring audio data

default 11:55:56.433945 -0800 replayd RPScreenCaptureManagerIOS: Screen sampled at w:886 h:1920

default 11:55:56.461486 -0800 replayd recorder is not running, ignoring audio data

Replies

In my case, I was using the FileManager's URL for saving the recording. I was using the below-mentioned code for creating the URL:

let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) let fileUrl = paths[0].appendingPathComponent("screenRecording-\(UUID().uuidString).mp4")

I have changed the way of creating URL. Instead of using FileManager I used NSTemporaryDirectory() as mentioned below: let fileURL: URL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("screenRecording-\(UUID().uuidString).mp4")

This resolved my issue.

Add a Comment