Prerequisites
- A working iOS quickstart
- A running Nosmai preview
Recording configuration
NosmaiCore starts its convenience recorder with native defaults and an automatically generated temporary MP4 URL. The start method has no bitrate, frame-rate, output-size, audio, or duration-limit argument. Dimensions are derived from the active preview; a camera capture preset is not itself an independent encoder-size configuration.
The headers contain NosmaiRecordingConfig, but the published NosmaiCore API does not expose a recordingConfiguration setter. Constructing this object alone does not configure Core recording. Do not document an assignment to a property that is not available in the public SDK.
To choose a destination while using the camera facade, the native API offers:
[[NosmaiCore shared].camera startRecordingToURL:outputURL
completion:^(NSError *error) {
if (error != nil) {
NSLog(@"Recording did not start: %@", error.localizedDescription);
}
}];
Use either this camera route or the Core convenience route below, not two simultaneous recorders. For independent codec, dimensions, bitrate, or custom audio mixing, route processed CVPixelBuffer output to an app-owned encoder; see Custom frame pipelines. Configure that encoder explicitly rather than expecting RTC publishing settings to configure the local recorder.
Audio requires the relevant permission and audio-session setup. Verify the final file rather than assuming its audio matches a live call. Implement a maximum-duration policy in the app, serialize its stop request with the record button, and wait for finalization before using the file.
Start recording
[[NosmaiCore shared] startRecordingWithCompletion:^(BOOL success, NSError *error) {
if (!success) {
NSLog(@"Recording did not start: %@", error.localizedDescription);
}
}];
Stop and receive the video
[[NosmaiCore shared] stopRecordingWithCompletion:^(NSURL *videoURL,
NSError *error) {
if (videoURL != nil) {
NSLog(@"Video ready at %@", videoURL);
return;
}
NSLog(@"Recording failed: %@", error.localizedDescription);
}];
The URL points to the finalized recording. Copy or export it before deleting temporary application data.
For status UI, use the Core recording state and elapsed duration:
BOOL recordingActive = [NosmaiCore shared].isRecording; NSTimeInterval elapsedSeconds = [[NosmaiCore shared] currentRecordingDuration];
Elapsed duration is a progress value, not a finalized-file result. Keep UI updates on the main queue and retain the recording owner until stop completion.
Lifecycle rule
Stop and finalize recording before switching camera, leaving the screen, or stopping processing. Ignore repeated record-button taps while a start or stop operation is in progress.
Verify it worked
Record a short clip with a visible effect, wait for the stop completion, and play the returned URL. Confirm orientation, effect output, duration, and audio.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| Recording does not start | The camera is not ready or recording is already active | Wait for preview startup and guard duplicate starts |
| The returned URL disappears later | The app kept a temporary URL without copying or exporting it | Move the finalized file before temporary data is cleaned |