{"record":{"id":"5aa7d1866ed2db7e","repo":"remotion-dev/remotion","slug":"unknown-video-source-type","errorCode":null,"errorMessage":"Unknown video source type","messagePattern":"Unknown video source type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/template-recorder/src/helpers/get-video-stream.ts","lineNumber":82,"sourceCode":"\n  // A string constraint is only an \"ideal\" preference. Use an exact\n  // constraint so Chrome cannot silently substitute the default microphone.\n  return { deviceId: { exact: selectedAudioSource } };\n};\n\nconst getCameraStram = ({\n  selectedVideoSource,\n  preferPortrait,\n  recordAudio,\n  selectedAudioSource,\n}: {\n  selectedVideoSource: SelectedSource;\n  preferPortrait: boolean;\n  recordAudio: boolean;\n  selectedAudioSource: string | null;\n}): Promise<MediaStream> => {\n  if (selectedVideoSource.type !== \"camera\") {\n    throw new Error(\"Unknown video source type\");\n  }\n  const video = getCameraStreamConstraints(selectedVideoSource, preferPortrait);\n\n  const mediaStreamConstraints: MediaStreamConstraints = {\n    video: video ?? undefined,\n    audio: getAudioStreamConstraints({ recordAudio, selectedAudioSource }),\n  };\n\n  return window.navigator.mediaDevices.getUserMedia(mediaStreamConstraints);\n};\n\nexport const getVideoStream = async ({\n  selectedVideoSource,\n  preferPortrait,\n  recordAudio,\n  selectedAudioSource,\n}: {\n  selectedVideoSource: SelectedSource;","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/template-recorder/src/helpers/get-video-stream.ts#L64-L100","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst stream = await getVideoStream({selectedVideoSource: screenSource, ...})\n// after\nif (screenSource.type === 'screen') {\n  stream = await getScreenStream(screenSource);\n} else {\n  stream = await getVideoStream({selectedVideoSource: screenSource, ...});\n}","handlingStrategy":"type-guard","validationCode":"if (selectedVideoSource.type !== 'camera') {\n  // route to the appropriate stream getter before calling getVideoStream\n}","typeGuard":"const isCameraSource = (s: SelectedSource): s is SelectedSource & {type: 'camera'} =>\n  s.type === 'camera';","tryCatchPattern":"try {\n  const stream = await getVideoStream(opts);\n} catch (e) {\n  if (e.message === 'Unknown video source type') {\n    // dispatch to getScreenStream or the matching handler\n  }\n}","preventionTips":["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"],"tags":["mediastream","template-recorder","type-mismatch"],"backgroundTag":"invalid-enum-value","analyzedSha":"46a3a6bf13ca367376ff18bbb06dae2e87e0d068","analyzedAt":"2026-09-18T00:12:20.256Z","contentChangedAt":"2026-09-18T00:12:20.256Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}