Effects Android
Effects / Guides / Video recording / Android

Record AR-filtered video on Android with Nosmai Effects

Updated August 22, 2026

Record the processed NosmaiPreviewView to an MP4 and handle completion without interrupting the camera pipeline.

Prerequisites

  • A working Android quickstart
  • The active NosmaiPreviewView
  • A writable absolute .mp4 output path

Recording configuration

NosmaiSDK.startRecording(previewView, outputPath, callback) is the public convenience recorder. It does not accept a bitrate/FPS/quality configuration object.

SettingPublic contract
OutputWritable absolute .mp4 path supplied by the app
DimensionsDerived from the processed preview frame; not an independent startRecording argument
Video defaultsTarget 30 FPS and 4,000,000 bits/second in this native release; actual delivery depends on processing and hardware
Maximum durationApp-owned policy; stop and finalize when the limit is reached
AudioVerify the actual output for the chosen path; do not assume the streaming provider's microphone track is recorded

Begin only after real processed frames arrive, not merely after creating a view. Use stable frame dimensions and even encoder dimensions. On measured lower-tier devices, the SDK can cap the recording's long edge at 1280 pixels to reduce encode load without reducing preview dimensions. A preview's layout size is not a promise of the saved file's resolution.

For a custom codec, fixed bitrate, microphone/audio mixing, or independently controlled output size, consume processed native output with an app-owned encoder; see Custom frame pipelines. Do not import internal recorder classes to configure this convenience API, or assume RTC publishing settings also configure a local recording.

Start recording

NosmaiSDK.startRecording(previewView, outputPath,
    new NosmaiSDK.RecordingCallback() {
        @Override
        public void onStarted(boolean success, String error) {
            if (!success) {
                Log.e("Nosmai", "Recording did not start: " + error);
            }
        }
    });

Disable duplicate start requests until onStarted returns.

Stop and finalize the MP4

NosmaiSDK.stopRecording(new NosmaiSDK.RecordingCallback() {
    @Override
    public void onCompleted(String path, boolean success, String error) {
        if (success) {
            Log.i("Nosmai", "Video ready at " + path);
        } else {
            Log.e("Nosmai", "Recording failed: " + error);
        }
    }
});

Wait for onCompleted before opening, sharing, or scanning the file. The callback path is the final result; handle success == false even if starting previously succeeded. Retain the preview and recording owner until finalization finishes. Dispatch UI changes to the main thread rather than assuming every completion is a UI callback.

Lifecycle rule

Stop and finalize recording before switching camera, pausing the activity, or destroying the preview. On measured lower-tier devices the SDK can reduce only the recording resolution to protect frame rate; the live preview remains at its configured size.

Keep start, stop, and any duration-limit timer under one serialized state machine. Cancel the timer when recording ends. A timer requesting stop does not mean that the file is already finalized.

Verify it worked

Record a short clip with a visible effect, wait for onCompleted, and play the returned MP4. Confirm its orientation, effect output, video duration, and audio.

Common errors

SymptomCauseFix
Recording does not startThe preview is not ready or another start is in progressWait for camera startup and guard the record button
The file cannot be openedThe app used it before onCompletedWait for finalization and use a writable absolute .mp4 path

Next steps

References

Nosmai

An AR and AI company. Founded on the idea that the next decade of software will be visual, and that the tools for it should be within reach of anyone building.

Newsletter

Product updates and release notes. No spam.

© 2026 nosmai, inc · all rights reserved