Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
refactor(camera): one answer to "does this asset have a camera"
Etienne Lescot12a12751d155
diff --git a/crates/compositor/src/timeline_walk.rs b/crates/compositor/src/timeline_walk.rsindex adde1d52b..c593a4863 100644--- a/crates/compositor/src/timeline_walk.rs+++ b/crates/compositor/src/timeline_walk.rs@@ -176,7 +176,18 @@ pub(crate) unsafe fn walk_composited_timeline(screen_decs.insert(clip.screen.clone(), Decoder::open(&clip.screen, gpu)?);}if !webcam_decs.contains_key(&clip.webcam) {- webcam_decs.insert(clip.webcam.clone(), Decoder::open(&clip.webcam, gpu)?);+ // Même repli que `live.rs::open_and_seek_clip` : un clip sans caméra arrive+ // avec un chemin webcam VIDE, que `Decoder::open` refuse. `set_has_webcam`+ // ci-dessus a déjà décidé qu'on ne dessine pas la PiP ; le décodeur n'est+ // ouvert que parce que `compose_frame` échantillonne deux flux+ // inconditionnellement, donc on lui redonne l'écran et ses images sont+ // ignorées. Sans ce repli, exporter un projet sans caméra échouerait net —+ // et c'est précisément le cas le plus courant (issue #348).+ let dec = match Decoder::open(&clip.webcam, gpu) {+ Ok(d) => d,+ Err(_) => Decoder::open(&clip.screen, gpu)?,+ };+ webcam_decs.insert(clip.webcam.clone(), dec);}let sdec = screen_decs.get_mut(&clip.screen).unwrap();let wdec = webcam_decs.get_mut(&clip.webcam).unwrap();diff --git a/src/cli/CliExportRunner.tsx b/src/cli/CliExportRunner.tsxindex f9c57c682..5b72eee1c 100644--- a/src/cli/CliExportRunner.tsx+++ b/src/cli/CliExportRunner.tsx@@ -23,6 +23,7 @@ import {import { applyProbedDuration } from "@/lib/ai-edition/document/timeline";import type { AxcutDocument } from "@/lib/ai-edition/schema";import { getEditorSettings } from "@/lib/ai-edition/store/editorSettings";+import { assetCameraSource } from "@/lib/ai-edition/timeline/camera";import { resolveClipSourceEndSec } from "@/lib/ai-edition/timeline/clipDuration";import { DEFAULT_ZOOM_DEPTH, ZOOM_DEPTH_SCALES } from "@/lib/ai-edition/timeline/zoom-scale";import { buildAutoZoomSuggestions } from "@/lib/ai-edition/timeline/zoom-suggestions";@@ -83,15 +84,15 @@ function buildNativeClipList(axcutDocument: AxcutDocument): CompositorClipInput[if (!asset?.originalPath) {return [];}- const cam = asset.cameraTrack;+ const camera = assetCameraSource(asset);const sourceEndSec = resolveClipSourceEndSec(clip, asset);return [{screenPath: asset.originalPath,- webcamPath: cam?.sourcePath ?? asset.originalPath,+ webcamPath: camera.path,sourceStartSec: clip.sourceStartSec,sourceEndSec,- webcamOffsetSec: cam ? (cam.startMs + cam.offsetMs) / 1000 : 0,+ webcamOffsetSec: camera.offsetSec,hasAudio: true,},];diff --git a/src/components/ai-edition/ExportDialog.tsx b/src/components/ai-edition/ExportDialog.tsxindex 901756989..e640fbd19 100644--- a/src/components/ai-edition/ExportDialog.tsx+++ b/src/components/ai-edition/ExportDialog.tsx@@ -20,6 +20,7 @@ import {} from "@/lib/ai-edition/document/outputFormat";import type { AxcutDocument } from "@/lib/ai-edition/schema";import { getEditorSettings } from "@/lib/ai-edition/store/editorSettings";+import { assetCameraSource } from "@/lib/ai-edition/timeline/camera";import { resolveClipSourceEndSec } from "@/lib/ai-edition/timeline/clipDuration";import {type ExportFormat,@@ -62,24 +63,21 @@ function buildNativeClipList(document: AxcutDocument): CompositorClipInput[] {if (!asset?.originalPath) {return [];}- const cam = asset.cameraTrack;+ const camera = assetCameraSource(asset);// sourceEndSec is optional in the schema (unknown until probed) — fall back through// the single canonical precedence used by every consumer (clip.probe → asset.duration// → timeline-length guess). See `resolveClipSourceEndSec` for the full order.const sourceEndSec = resolveClipSourceEndSec(clip, asset);- // ponytail: matches the rule in `buildSceneDescription` — screen recordings- // from this app always carry a decodable audio track (the webcam path- // never does), so the only clips that reach this branch already have audio.- // If a per-asset audio-probe flag lands on the schema later, swap to- // `Boolean(asset.audio)` here too and keep these two derivation paths in- // lock-step with `buildSceneDescription` in src/native/sceneDescription.ts.+ // ponytail: `hasAudio` stays optimistic for the same reason as in+ // `buildSceneDescription` — nothing populates `asset.audio` yet, and the+ // native side degrades cleanly on a stream-less file.return [{screenPath: asset.originalPath,- webcamPath: cam?.sourcePath ?? asset.originalPath,+ webcamPath: camera.path,sourceStartSec: clip.sourceStartSec,sourceEndSec,- webcamOffsetSec: cam ? (cam.startMs + cam.offsetMs) / 1000 : 0,+ webcamOffsetSec: camera.offsetSec,hasAudio: true,},];diff --git a/src/components/ai-edition/NativeCompositorOverlay.tsx b/src/components/ai-edition/NativeCompositorOverlay.tsxindex 198cf89b5..710e90c74 100644--- a/src/components/ai-edition/NativeCompositorOverlay.tsx+++ b/src/components/ai-edition/NativeCompositorOverlay.tsx@@ -3,6 +3,7 @@ import { useScopedT } from "@/contexts/I18nContext";import { noteUiProbeClipSwitch } from "@/lib/ai-edition/perf/uiFrameProbe";import { getEditorSettings } from "@/lib/ai-edition/store/editorSettings";import { useProjectStore } from "@/lib/ai-edition/store/projectStore";+import { assetCameraSource } from "@/lib/ai-edition/timeline/camera";import { resolveNativePosition } from "@/lib/ai-edition/timeline/timelineMap";import {pushAllNativeParams,@@ -89,12 +90,12 @@ export function NativeCompositorOverlay() {if (!primary?.originalPath) {return {};}+ // `undefined` rather than `""` here ONLY because `useNativeCompositorView`+ // treats the key's absence as "no webcam source"; the value still comes from+ // the one accessor, so it can never disagree with the scene or the export.return {screenPath: primary.originalPath,- webcamPath:- primary.cameraTrack?.visible && primary.cameraTrack.sourcePath- ? primary.cameraTrack.sourcePath- : undefined,+ webcamPath: assetCameraSource(primary).path || undefined,// sidecar convention (electron/ipc/handlers.ts readCursorRecordingFile) : la// télémétrie curseur vit à côté de la vidéo tant qu'elle n'a pas bougé. Absente →// le natif ignore juste le curseur (CursorTrack::load échoue silencieusement).@@ -196,8 +197,7 @@ export function NativeCompositorOverlay() {if (!asset?.originalPath) {return;}- const cam = asset.cameraTrack;- const webcamPath = cam && cam.visible && cam.sourcePath ? cam.sourcePath : "";+ const camera = assetCameraSource(asset);const targetClipId = activeClipId;// Sonde de fluidité (diagnostic) : sépare les mesures d'avant et d'après un// franchissement de clip, qui se sont déjà révélées non comparables.@@ -214,8 +214,8 @@ export function NativeCompositorOverlay() {setActiveClip(viewId,asset.originalPath,- webcamPath,- cam ? (cam.startMs + cam.offsetMs) / 1000 : 0,+ camera.path,+ camera.offsetSec,activeClipIndex,activeSourceTimeSec,)diff --git a/src/lib/ai-edition/timeline/camera.test.ts b/src/lib/ai-edition/timeline/camera.test.tsindex 95aaa505a..2dbb2b3bc 100644--- a/src/lib/ai-edition/timeline/camera.test.ts+++ b/src/lib/ai-edition/timeline/camera.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";import type { AxcutAsset, AxcutClip } from "../schema";-import { hasAnyClipWithCamera, resolveActiveCameraTrack } from "./camera";+import { assetCameraSource, hasAnyClipWithCamera, resolveActiveCameraTrack } from "./camera";const assetWithCamera: AxcutAsset = {id: "asset_with_camera",@@ -111,3 +111,35 @@ describe("hasAnyClipWithCamera", () => {expect(hasAnyClipWithCamera([], [])).toBe(false);});});++// The single spelling of "no camera". Five producers used to answer this+// question five different ways (empty string, undefined, and — in both export+// paths — the SCREEN recording's own path, which is issue #265's defect shape).+// They all route through assetCameraSource now; this is what pins it.+describe("assetCameraSource", () => {+ it("returns the camera path and its start offset in seconds", () => {+ const asset: AxcutAsset = {+ ...assetWithCamera,+ cameraTrack: { sourcePath: "/cam-1.mp4", startMs: 500, offsetMs: -200, visible: true },+ };+ expect(assetCameraSource(asset)).toEqual({ path: "/cam-1.mp4", offsetSec: 0.3 });+ });++ it('says "no camera" with an empty path — NEVER the screen recording', () => {+ expect(assetCameraSource(assetWithoutCamera)).toEqual({ path: "", offsetSec: 0 });+ // The banned fallback: substituting originalPath makes "no camera"+ // indistinguishable from "the camera IS this file", and the native side+ // then has to tell them apart by string comparison.+ expect(assetCameraSource(assetWithoutCamera).path).not.toBe(assetWithoutCamera.originalPath);+ });++ it("treats a hidden camera as no camera", () => {+ // The export producers used to ignore `visible` while the preview and the+ // scene honoured it — the same project rendered two different ways.+ expect(assetCameraSource(assetWithHiddenCamera)).toEqual({ path: "", offsetSec: 0 });+ });++ it("tolerates a missing asset", () => {+ expect(assetCameraSource(undefined)).toEqual({ path: "", offsetSec: 0 });+ });+});diff --git a/src/lib/ai-edition/timeline/camera.ts b/src/lib/ai-edition/timeline/camera.tsindex 8b1c96746..4fc576952 100644--- a/src/lib/ai-edition/timeline/camera.ts+++ b/src/lib/ai-edition/timeline/camera.ts@@ -22,3 +22,31 @@ export function resolveActiveCameraTrack(export function hasAnyClipWithCamera(assets: AxcutAsset[], clips: AxcutClip[]): boolean {return clips.some((clip) => assets.find((a) => a.id === clip.assetId)?.cameraTrack != null);}++/**+ * THE answer to "which camera file does this asset contribute, and where does it+ * start". Every producer of a `CompositorClipInput` — the scene, the preview+ * overlay, the export dialog, the CLI exporter — must go through this, because+ * the native side compares the webcam path against the screen path to decide+ * whether a PiP gets drawn at all (`webcam_is_real`, frame_geometry.rs).+ *+ * `path: ""` is the ONE way to say "no camera". The alternative that used to+ * live in the export producers — substituting `asset.originalPath` — is banned:+ * it makes "no camera" indistinguishable from "the camera happens to be the+ * screen file", and it only ever worked because both fields were filled from+ * the same variable, so the two strings matched byte for byte. Any producer that+ * derived one of them differently (a separator, a case, a resolved vs. raw path+ * — all routine on Windows) would have re-opened issue #265, where the screen+ * recording is drawn into the webcam slot.+ *+ * `visible: false` counts as no camera, matching what the preview and scene+ * already did and what the export producers did NOT.+ */+export function assetCameraSource(asset: AxcutAsset | undefined): {+ path: string;+ offsetSec: number;+} {+ const cam = asset?.cameraTrack;+ if (!cam?.visible || !cam.sourcePath) return { path: "", offsetSec: 0 };+ return { path: cam.sourcePath, offsetSec: (cam.startMs + cam.offsetMs) / 1000 };+}diff --git a/src/native/sceneDescription.ts b/src/native/sceneDescription.tsindex ae4beb5d9..7186d66e5 100644--- a/src/native/sceneDescription.ts+++ b/src/native/sceneDescription.ts@@ -29,6 +29,7 @@ import { pickOutputDims } from "@/lib/ai-edition/document/outputFormat";import { resolvePlaybackSegments } from "@/lib/ai-edition/document/timeline";import type { AxcutClip, AxcutDocument } from "@/lib/ai-edition/schema";import { getEditorSettings } from "@/lib/ai-edition/store/editorSettings";+import { assetCameraSource } from "@/lib/ai-edition/timeline/camera";import { resolveClipSourceEndSec } from "@/lib/ai-edition/timeline/clipDuration";import { projectRegionsToSource } from "@/lib/ai-edition/timeline/timelineMap";import {@@ -417,24 +418,21 @@ export function buildSceneDescription(const clips: CompositorClipInput[] = visibleClips.flatMap((clip) => {const asset = assetById.get(clip.assetId);if (!asset?.originalPath) return [];- const cam = asset.cameraTrack;- // ponytail: screen recordings from this app always carry a decodable audio- // track (confirmed via ffprobe on real recordings); webcam files never do- // and clips only ever reference their SCREEN path for the main video. The- // `asset.audio` schema slot exists but is never populated by the probe- // pipeline today, so we can't rely on it as an "is there a track?" signal —- // matching the legacy web exporter (which just tries-and-catches in- // `decodeSegmentAudioPcm`), we default `hasAudio: true` for every clip whose- // asset has an `originalPath`. The visibleClips filter above already- // guarantees that precondition by the time we reach this branch. If a- // per-asset audio-probe flag is added later, swap to `Boolean(asset.audio)`.+ const camera = assetCameraSource(asset);+ // ponytail: `asset.audio` exists in the schema but the probe pipeline never+ // populates it, so there is no per-asset "is there a track?" signal to read+ // yet. Every consumer downstream degrades on a stream-less file (audio.rs+ // returns Ok(None)), so this stays optimistic. NOT "recordings always carry+ // audio" — a capture made with no mic and no system audio has no audio+ // stream at all (issue #348). Swap to `Boolean(asset.audio)` the day the+ // probe fills it in.return [{screenPath: asset.originalPath,- webcamPath: cam && cam.visible && cam.sourcePath ? cam.sourcePath : "",+ webcamPath: camera.path,sourceStartSec: clip.sourceStartSec,sourceEndSec: resolveClipSourceEndSec(clip, asset),- webcamOffsetSec: cam ? (cam.startMs + cam.offsetMs) / 1000 : 0,+ webcamOffsetSec: camera.offsetSec,hasAudio: true,},];@@ -575,10 +573,8 @@ export function buildSceneDescription(* with the clip above, so the layout and the decoder can never disagree about it.* Note this is NOT `hasAnyClipWithCamera` (which gates the Layout panel): that one* ignores `visible` on purpose, so the panel stays reachable to un-hide a camera. */- const clipHasCamera = (clip: AxcutClip) => {- const cam = assetById.get(clip.assetId)?.cameraTrack;- return Boolean(cam?.visible && cam.sourcePath);- };+ const clipHasCamera = (clip: AxcutClip) =>+ assetCameraSource(assetById.get(clip.assetId)).path !== "";/*** The layout preset is GLOBAL — one panel for the whole timeline — but the camera is* per clip: a project mixes a screen+webcam recording with a plain import that has