remotion-dev/remotion · error
Unknown video source type
Error message
Unknown video source type
What it means
getCameraStram only handles camera-type video sources; it is a guard at the top of the function. If the selected video source is not of type 'camera', the function has no way to build MediaStream constraints and throws 'Unknown video source type'. Callers (getVideoStream) should dispatch screen/other source types elsewhere.
Solutions
- Route non-camera sources (e.g. type 'screen') to their dedicated stream acquisition function instead of getVideoStream
- Ensure the recorder state stores the correct SelectedSource type before requesting the stream
- Add a discriminant check on selectedVideoSource.type in the caller and branch accordingly
Example fix
// before
const stream = await getVideoStream({selectedVideoSource: screenSource, ...})
// after
if (screenSource.type === 'screen') {
stream = await getScreenStream(screenSource);
} else {
stream = await getVideoStream({selectedVideoSource: screenSource, ...});
} Defensive patterns
Strategy: type-guard
Validate before calling
if (selectedVideoSource.type !== 'camera') {
// route to the appropriate stream getter before calling getVideoStream
} Type guard
const isCameraSource = (s: SelectedSource): s is SelectedSource & {type: 'camera'} =>
s.type === 'camera'; Try / catch
try {
const stream = await getVideoStream(opts);
} catch (e) {
if (e.message === 'Unknown video source type') {
// dispatch to getScreenStream or the matching handler
}
} Prevention
- Branch on selectedVideoSource.type in the caller before requesting streams
- Keep recorder UI state and stream-acquisition path in sync
- Never pass screen sources through camera-only helpers
When it happens
Trigger: Calling getVideoStream/getCameraStram with a SelectedSource whose type is 'screen' or any non-camera variant — e.g. the recorder was configured for screen sharing but routed through the camera path.
Common situations: A recorder UI state mismatch where the selected source type changed but the stream-acquisition path did not; passing a stale or default source object; mixing up the screen-recording and camera-recording code paths.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Cannot update effect prop: computed
- Component style must be an object to add a position
- Expected an image, video, or canvas element
- Expected an in-memory output target
- model must be a string.
AI-assisted analysis of remotion-dev/remotion@46a3a6bf13 (2026-09-18).
Data as JSON: /api/errors/5aa7d1866ed2db7e.
Report an issue: GitHub.
Appendix: source
Thrown at packages/template-recorder/src/helpers/get-video-stream.ts:82
// A string constraint is only an "ideal" preference. Use an exact
// constraint so Chrome cannot silently substitute the default microphone.
return { deviceId: { exact: selectedAudioSource } };
};
const getCameraStram = ({
selectedVideoSource,
preferPortrait,
recordAudio,
selectedAudioSource,
}: {
selectedVideoSource: SelectedSource;
preferPortrait: boolean;
recordAudio: boolean;
selectedAudioSource: string | null;
}): Promise<MediaStream> => {
if (selectedVideoSource.type !== "camera") {
throw new Error("Unknown video source type");
}
const video = getCameraStreamConstraints(selectedVideoSource, preferPortrait);
const mediaStreamConstraints: MediaStreamConstraints = {
video: video ?? undefined,
audio: getAudioStreamConstraints({ recordAudio, selectedAudioSource }),
};
return window.navigator.mediaDevices.getUserMedia(mediaStreamConstraints);
};
export const getVideoStream = async ({
selectedVideoSource,
preferPortrait,
recordAudio,
selectedAudioSource,
}: {
selectedVideoSource: SelectedSource;View on GitHub (pinned to 46a3a6bf13)