Replies: 1 comment 1 reply
-
|
The following changes are required:
// Error monitoring
errorTask = Task {
for await error in recorder.error {
await recoverRecording()
}
}
func recoverRecording() async {
// Is this necessary? It throws failedToFinishWriting.
_ = try? await recorder.stopRecording()
stream.removeOutout(recorder)
// You must cancel error handler.
errorTask?.cancel()
// Create fresh instance — is this the right approach?
recorder = StreamRecorder()
await recorder.setMovieFragmentInterval(60.0)
// Re-attach — do we need to remove the old recorder first?
await stream.addOutput(recorder)
// Start new recording with a new file URL
try? await recorder.startRecording(newOutputURL, settings: [...])
// Re-attach errorTask
errorTask = Task {
for await error in recorder.error {
await recoverRecording()
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question
When
AVAssetWriterenters.failedstate mid-recording withHaishinKit.StreamRecorder.Error error 5., what is the correct way to recover and resume recording withStreamRecorder?After the failure we observe:
errorAsyncStream yieldsfailedToAppendcontinuously.isRecordingremainstrue.stopRecording()throwsfailedToFinishWritingbecausewriter.statusis no longer.writing.Specific questions:
AVAssetWriterenters.failedstate, should we callstopRecording()at all, or just abandon the recorder instance?StreamRecorderand re-attaching viastream.addOutput()the intended way to resume?stream.removeOutput()?Background / Tried Steps
We use
StreamRecorderto record locally viaMediaMixer→RTMPStream→StreamRecorder(when streaming) orMediaMixer→StreamRecorder(record-only mode), withmovieFragmentIntervalset to 60 seconds.This is the exception we see consistently via the
errorAsyncStream when the writer fails mid-recording (failedToAppend):After this initial failure,
failedToAppendcontinues to yield on every subsequent sample buffer, and callingstopRecording()throwsfailedToFinishWritingbecause the writer is no longer in.writingstate.Our setup:
Our current recovery attempt:
Context: We build a live streaming app for recording funeral and memorial services. Our users are non-technical, typically funeral home staff operating an iPad/iPhone on a tripod. When a recording fails silently, the family's once-in-a-lifetime event is lost. What we're struggling with is reliably resuming recording after the failure so we capture the rest of the service.
And just signed up as a sponsor, so any guidance on the intended recovery pattern would be much appreciated.
Environment
.movwithmovieFragmentInterval(60.0)Beta Was this translation helpful? Give feedback.
All reactions