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
feat(poc-d3d): native multiclip export over the real timeline
Etienne Lescotd01ed4d79003
diff --git a/electron/ipc/nativeBridge.ts b/electron/ipc/nativeBridge.tsindex 0538b4201..31fe5ec76 100644--- a/electron/ipc/nativeBridge.ts+++ b/electron/ipc/nativeBridge.ts@@ -394,6 +394,20 @@ export function registerNativeBridgeHandlers(context: NativeBridgeContext) {}return createSuccessResponse(requestId, stats);}+ case "exportMulti": {+ const stats = await compositorViewService.exportMulti(+ request.payload.clips,+ request.payload.outPath,+ );+ if (!stats) {+ return createErrorResponse(+ requestId,+ "UNAVAILABLE",+ "Native compositor addon not present.",+ );+ }+ return createSuccessResponse(requestId, stats);+ }default:return createErrorResponse(requestId,diff --git a/electron/native-bridge/services/compositorViewService.ts b/electron/native-bridge/services/compositorViewService.tsindex 2df243590..caffd6974 100644--- a/electron/native-bridge/services/compositorViewService.ts+++ b/electron/native-bridge/services/compositorViewService.ts@@ -4,6 +4,7 @@ import path from "node:path";import { fileURLToPath } from "node:url";import { app } from "electron";import type {+ ClipInput,CompositorParamValue,CompositorViewAddon,CompositorViewRect,@@ -234,4 +235,15 @@ export class CompositorViewService {const target = outPath ?? path.join(app.getPath("temp"), "openscreen-native-export.mp4");return addon.export(target);}++ /** Native multiclip export (real timeline -> MP4). Auto-pauses previews via the addon.+ * Returns null when the addon is absent. */+ async exportMulti(clips: ClipInput[], outPath?: string): Promise<ExportStats | null> {+ const addon = this.ensureAddon();+ if (!addon) {+ return null;+ }+ const target = outPath ?? path.join(app.getPath("temp"), "openscreen-native-export.mp4");+ return addon.exportMulti(clips, target);+ }}diff --git a/electron/native/compositor-view/addon.d.ts b/electron/native/compositor-view/addon.d.tsindex 0e082a896..7d6d4f7a2 100644--- a/electron/native/compositor-view/addon.d.ts+++ b/electron/native/compositor-view/addon.d.ts@@ -22,6 +22,16 @@ export interface ExportStats {fps: number;}+/** One timeline clip for the native multiclip export (screen + webcam files + source trim). */+export interface ClipInput {+ screenPath: string;+ webcamPath: string;+ sourceStartSec: number;+ sourceEndSec: number;+ /** webcam source time = screen source time − this. */+ webcamOffsetSec: number;+}+export interface CompositorViewAddon {/** Optional screen/webcam/cursor paths (F3 — the app's real recording, two separate H264* files); omitted → the POC fixture. */@@ -40,6 +50,8 @@ export interface CompositorViewAddon {destroyView(id: number): void;/** Renders the fixture to `outPath` (C8), auto-pausing live previews. */export(outPath: string): Promise<ExportStats>;+ /** Renders the real timeline (ordered clips + trims) to `outPath`, auto-pausing previews. */+ exportMulti(clips: ClipInput[], outPath: string): Promise<ExportStats>;}/**diff --git a/poc-d3d/compositor-view-napi/src/lib.rs b/poc-d3d/compositor-view-napi/src/lib.rsindex 2f033e761..7b48f2ba2 100644--- a/poc-d3d/compositor-view-napi/src/lib.rs+++ b/poc-d3d/compositor-view-napi/src/lib.rs@@ -197,3 +197,72 @@ impl Task for ExportTask {pub fn export(out_path: String) -> AsyncTask<ExportTask> {AsyncTask::new(ExportTask { out_path })}++/// Un clip de la timeline pour l'export multiclip (JS : camelCase).+#[napi(object)]+pub struct ClipInput {+ pub screen_path: String,+ pub webcam_path: String,+ pub source_start_sec: f64,+ pub source_end_sec: f64,+ /// Décalage caméra (s) : temps source webcam = temps source screen - offset.+ pub webcam_offset_sec: f64,+}++/// Export multiclip mesuré (worker libuv). Rend la vraie timeline (clips + trims) en un MP4.+/// Layout statique (zoom/anim off, motion blur de layout off, curseur off) → composite propre+/// des vraies sources sans surcoût. Réactive les previews après le rendu (même en erreur).+pub struct ExportMultiTask {+ out_path: String,+ clips: Vec<pipeline::ClipSource>,+}++impl Task for ExportMultiTask {+ type Output = (u32, f64, f64);+ type JsValue = ExportStats;++ fn compute(&mut self) -> Result<Self::Output> {+ set_all_previews_playing(false);+ let result = (|| {+ let gpu = Gpu::create(false).map_err(|e| Error::from_reason(format!("{e:#}")))?;+ let comp = Compositor::new(&gpu).map_err(|e| Error::from_reason(format!("{e:#}")))?;+ let mut cfg = config::all().pop().expect("au moins une config"); // C8+ cfg.zoom = false;+ cfg.layout_anim = false;+ cfg.cursor = false; // pas de télémétrie curseur mappée encore+ cfg.mblur_n = 1; // layout statique → pas de motion blur de layout (pas de surcoût)+ let s = pipeline::run_composited_multi(+ &self.clips,+ &self.out_path,+ &gpu,+ &comp,+ &cfg,+ &mut |_| {},+ )+ .map_err(|e| Error::from_reason(format!("{e:#}")))?;+ Ok((s.frames as u32, s.wall_s, s.fps))+ })();+ set_all_previews_playing(true);+ result+ }++ fn resolve(&mut self, _env: Env, out: Self::Output) -> Result<Self::JsValue> {+ Ok(ExportStats { frames: out.0, wall_s: out.1, fps: out.2 })+ }+}++/// Lance un export multiclip natif (vraie timeline → MP4) et résout `Promise<ExportStats>`.+#[napi]+pub fn export_multi(clips: Vec<ClipInput>, out_path: String) -> AsyncTask<ExportMultiTask> {+ let clips = clips+ .into_iter()+ .map(|c| pipeline::ClipSource {+ screen: c.screen_path,+ webcam: c.webcam_path,+ source_start_sec: c.source_start_sec,+ source_end_sec: c.source_end_sec,+ webcam_offset_sec: c.webcam_offset_sec,+ })+ .collect();+ AsyncTask::new(ExportMultiTask { out_path, clips })+}diff --git a/poc-d3d/src/pipeline.rs b/poc-d3d/src/pipeline.rsindex 4a1f7b06e..39a10d268 100644--- a/poc-d3d/src/pipeline.rs+++ b/poc-d3d/src/pipeline.rs@@ -7,6 +7,7 @@ use crate::config::Cfg;use crate::d3d::Gpu;use crate::ffi::*;use anyhow::{anyhow, bail, Result};+use std::collections::HashMap;use std::ffi::{c_void, CString};use std::ptr;use std::time::Instant;@@ -417,6 +418,50 @@ impl Decoder {Ok(())}+ /// Time_base du flux vidéo (secondes par unité de pts).+ unsafe fn tb_sec(&self) -> f64 {+ let tb = (*sn_fmt_stream(self.fmt, self.vidx)).time_base;+ if tb.den != 0 { tb.num as f64 / tb.den as f64 } else { 0.0 }+ }++ /// Seek keyframe vers `seconds` puis décode-avant jusqu'à la 1re frame dont le temps+ /// ≥ `seconds`. Réutilise le décodeur ouvert (pas de réouverture) : c'est LE point de+ /// perf multiclip — un seul seek par frontière de clip, décodage séquentiel ensuite,+ /// donc le débit par frame ne change pas. Renvoie la frame (ou null à EOF).+ pub(crate) unsafe fn seek_to(&mut self, seconds: f64) -> Result<*mut AVFrame> {+ let tb_sec = self.tb_sec();+ let target = if tb_sec > 0.0 { (seconds / tb_sec) as i64 } else { 0 };+ averr(av_seek_frame(self.fmt, self.vidx, target, AVSEEK_FLAG_BACKWARD), "seek_to")?;+ avcodec_flush_buffers(self.dctx);+ self.sent_eof = false;+ loop {+ let f = self.next()?;+ if f.is_null() {+ return Ok(ptr::null_mut());+ }+ let pts = (*f).best_effort_timestamp;+ // pas de pts fiable ou pas de time_base → on prend la 1re frame après la keyframe.+ if pts == i64::MIN || tb_sec <= 0.0 {+ return Ok(f);+ }+ if (pts as f64) * tb_sec >= seconds - tb_sec * 0.5 {+ return Ok(f);+ }+ }+ }++ /// Temps (s) de la frame courante, via son pts. 0 si pas de pts fiable.+ pub(crate) unsafe fn cur_time_sec(&self) -> f64 {+ let pts = (*self.frame).best_effort_timestamp;+ if pts == i64::MIN { 0.0 } else { pts as f64 * self.tb_sec() }+ }++ /// Cadence moyenne du flux (fps). 30 par défaut si indéterminée.+ pub(crate) unsafe fn fps(&self) -> f64 {+ let r = (*sn_fmt_stream(self.fmt, self.vidx)).avg_frame_rate;+ if r.den != 0 && r.num != 0 { r.num as f64 / r.den as f64 } else { 30.0 }+ }+/// Rend la prochaine frame (valide jusqu'au prochain appel), ou null à EOF.pub(crate) unsafe fn next(&mut self) -> Result<*mut AVFrame> {loop {@@ -594,6 +639,156 @@ unsafe fn run_c1_inner(Ok(Stats { frames, wall_s, fps })}+/// Une source de clip pour l'export multiclip : fichiers screen+webcam + fenêtre source+/// (trim, en secondes). `webcam_offset_sec` : temps source webcam = temps source screen - offset.+pub struct ClipSource {+ pub screen: String,+ pub webcam: String,+ pub source_start_sec: f64,+ pub source_end_sec: f64,+ pub webcam_offset_sec: f64,+}++/// Export **multiclip** : rend la timeline (clips ordonnés, avec trims) en un seul MP4.+/// Perf (contrainte §multiclip) : décodeurs ouverts une fois par source (cache) et réutilisés+/// entre clips du même asset ; **un seul seek keyframe par frontière de clip** ; décodage+/// séquentiel dans le clip → coût/frame identique au mono-clip (~120fps préservés). Cadence de+/// sortie = fps du 1er clip (la conversion de cadence viendra avec les params d'export).+pub fn run_composited_multi(+ clips: &[ClipSource],+ out: &str,+ gpu: &Gpu,+ comp: &Compositor,+ cfg: &Cfg,+ progress: &mut dyn FnMut(u64),+) -> Result<Stats> {+ unsafe { run_multi_inner(clips, out, gpu, comp, cfg, progress) }+}++unsafe fn run_multi_inner(+ clips: &[ClipSource],+ out: &str,+ gpu: &Gpu,+ comp: &Compositor,+ cfg: &Cfg,+ progress: &mut dyn FnMut(u64),+) -> Result<Stats> {+ if clips.is_empty() {+ bail!("aucun clip à exporter");+ }+ // décodeurs ouverts une fois par chemin, réutilisés entre clips (screen ≠ webcam → 2 maps+ // pour deux &mut indépendants).+ let mut screen_decs: HashMap<String, Decoder> = HashMap::new();+ let mut webcam_decs: HashMap<String, Decoder> = HashMap::new();++ // fps de sortie = fps du 1er clip (recordings uniformes).+ screen_decs.insert(clips[0].screen.clone(), Decoder::open(&clips[0].screen, gpu)?);+ let out_fps = screen_decs[&clips[0].screen].fps().round().max(1.0) as i32;++ // ---- encodeur h264_amf + mux (identique à run_c1_inner, à la cadence près) ----+ let (mut enc_hwdev, mut enc_frames) = make_enc_frames(gpu, OUT_W as i32, OUT_H as i32)?;+ let enc_name = CString::new("h264_amf")?;+ let enc = avcodec_find_encoder_by_name(enc_name.as_ptr());+ if enc.is_null() {+ bail!("h264_amf introuvable");+ }+ let ectx = avcodec_alloc_context3(enc);+ (*ectx).width = OUT_W as i32;+ (*ectx).height = OUT_H as i32;+ (*ectx).pix_fmt = AVPixelFormat::AV_PIX_FMT_D3D11;+ (*ectx).time_base = AVRational { num: 1, den: out_fps };+ (*ectx).framerate = AVRational { num: out_fps, den: 1 };+ (*ectx).bit_rate = 8_000_000;+ (*ectx).hw_frames_ctx = av_buffer_ref(enc_frames);+ averr(avcodec_open2(ectx, enc, ptr::null_mut()), "avcodec_open2(enc)")?;++ let mut octx: *mut AVFormatContext = ptr::null_mut();+ let outc = CString::new(out)?;+ averr(+ avformat_alloc_output_context2(&mut octx, ptr::null(), ptr::null(), outc.as_ptr()),+ "alloc_output_context2",+ )?;+ let ostream = avformat_new_stream(octx, ptr::null());+ averr(avcodec_parameters_from_context((*ostream).codecpar, ectx), "params_from_ctx")?;+ (*ostream).time_base = (*ectx).time_base;+ let mut pb: *mut AVIOContext = ptr::null_mut();+ averr(avio_open(&mut pb, outc.as_ptr(), AVIO_FLAG_WRITE as i32), "avio_open")?;+ sn_fmt_set_pb(octx, pb);+ averr(avformat_write_header(octx, ptr::null_mut()), "write_header")?;++ let opkt = av_packet_alloc();+ let mut frames: u64 = 0;+ let t0 = Instant::now();++ for clip in clips {+ if !screen_decs.contains_key(&clip.screen) {+ 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)?);+ }+ let sdec = screen_decs.get_mut(&clip.screen).unwrap();+ let wdec = webcam_decs.get_mut(&clip.webcam).unwrap();++ // un seul seek keyframe, puis décodage séquentiel jusqu'à source_end.+ if sdec.seek_to(clip.source_start_sec)?.is_null() {+ continue; // clip vide / au-delà de la source+ }+ wdec.seek_to((clip.source_start_sec - clip.webcam_offset_sec).max(0.0))?;++ loop {+ let sf = sdec.cur_frame();+ let wf = wdec.cur_frame();+ if sf.is_null() || wf.is_null() {+ break;+ }+ if sdec.cur_time_sec() >= clip.source_end_sec {+ break;+ }+ comp.compose_frame(sf, wf, frames as f32, cfg)?;++ let outf = av_frame_alloc();+ averr(av_hwframe_get_buffer(enc_frames, outf, 0), "hwframe_get_buffer")?;+ let out_tex = (*outf).data[0] as *mut c_void;+ let out_slice = (*outf).data[1] as u32;+ comp.rgb_to_nv12(out_tex, out_slice)?;+ (*outf).pts = frames as i64;+ averr(avcodec_send_frame(ectx, outf), "send_frame")?;+ drain_encoder(ectx, octx, ostream, opkt)?;+ av_frame_free(&mut (outf as *mut _));+ frames += 1;+ progress(frames);++ if sdec.next()?.is_null() {+ break;+ }+ if wdec.next()?.is_null() {+ break;+ }+ }+ }++ avcodec_send_frame(ectx, ptr::null_mut());+ drain_encoder(ectx, octx, ostream, opkt)?;+ averr(av_write_trailer(octx), "write_trailer")?;+ let wall_s = t0.elapsed().as_secs_f64();++ // teardown (les décodeurs du cache sont droppés en fin de scope).+ av_packet_free(&mut (opkt as *mut _));+ let mut pb2 = sn_fmt_get_pb(octx);+ if !pb2.is_null() {+ avio_closep(&mut pb2);+ sn_fmt_set_pb(octx, ptr::null_mut());+ }+ avformat_free_context(octx);+ avcodec_free_context(&mut (ectx as *mut _));+ av_buffer_unref(&mut enc_frames);+ av_buffer_unref(&mut enc_hwdev);++ let fps = frames as f64 / wall_s;+ Ok(Stats { frames, wall_s, fps })+}+unsafe fn drain_encoder(ectx: *mut AVCodecContext,octx: *mut AVFormatContext,diff --git a/src/components/ai-edition/ExportDialog.tsx b/src/components/ai-edition/ExportDialog.tsxindex 68eb7ac99..49760d666 100644--- a/src/components/ai-edition/ExportDialog.tsx+++ b/src/components/ai-edition/ExportDialog.tsx@@ -28,8 +28,9 @@ import {type GifSizePreset,} from "@/lib/exporter";import { calculateMp4ExportSettings } from "@/lib/exporter/mp4ExportSettings";-import { exportNative } from "@/native";+import { exportMultiNative, exportNative } from "@/native";import { nativeBridgeClient } from "@/native/client";+import type { CompositorClipInput } from "@/native/contracts";import {type AspectRatio,getAspectRatioValue,@@ -41,6 +42,35 @@ import { NATIVE_COMPOSITOR_ENABLED } from "./Preview";type Phase = "idle" | "configuring" | "rendering" | "writing" | "done" | "error";+/** Maps the document's timeline to the native multiclip export contract: ordered clips, each+ * with its asset's screen file + camera file (falls back to the screen when a clip has no+ * camera — the no-webcam layout is a later step) and its source trim. */+function buildNativeClipList(document: AxcutDocument): CompositorClipInput[] {+ const assetById = new Map(document.assets.map((a) => [a.id, a]));+ return [...document.timeline.clips]+ .sort((a, b) => a.timelineStartSec - b.timelineStartSec)+ .flatMap((clip) => {+ const asset = assetById.get(clip.assetId);+ if (!asset?.originalPath) {+ return [];+ }+ const cam = asset.cameraTrack;+ // sourceEndSec is optional in the schema (unknown until probed) — fall back to the+ // clip's timeline duration (speed 1).+ const sourceEndSec =+ clip.sourceEndSec ?? clip.sourceStartSec + (clip.timelineEndSec - clip.timelineStartSec);+ return [+ {+ screenPath: asset.originalPath,+ webcamPath: cam?.sourcePath ?? asset.originalPath,+ sourceStartSec: clip.sourceStartSec,+ sourceEndSec,+ webcamOffsetSec: cam ? (cam.startMs + cam.offsetMs) / 1000 : 0,+ },+ ];+ });+}+// Target short side (px) for the two fixed quality tiers -- mirrors the legacy// editor's SettingsPanel (MP4_EXPORT_SHORT_SIDES), used only to decide whether// picking that tier would upscale past the source's actual resolution.@@ -192,7 +222,12 @@ export function ExportDialog({ open, onClose, document }: ExportDialogProps) {if (NATIVE_COMPOSITOR_ENABLED) {setPhase("rendering");try {- const stats = await exportNative(pickedPath);+ // Render the real timeline when there are clips; else fall back to the fixture.+ const clips = buildNativeClipList(document);+ const stats =+ clips.length > 0+ ? await exportMultiNative(clips, pickedPath)+ : await exportNative(pickedPath);setSavedPath(pickedPath);setPhase("done");toast.success(t("exportDialog.exportedVideo"), {diff --git a/src/components/ai-edition/NativeCompositorOverlay.tsx b/src/components/ai-edition/NativeCompositorOverlay.tsxindex db7f22fdb..d8e364f04 100644--- a/src/components/ai-edition/NativeCompositorOverlay.tsx+++ b/src/components/ai-edition/NativeCompositorOverlay.tsx@@ -1,4 +1,5 @@-import { useEffect, useRef, useState } from "react";+import { useEffect, useMemo, useRef } from "react";+import { useProjectStore } from "@/lib/ai-edition/store/projectStore";import { setCurrentNativeViewId, useNativeCompositorView } from "@/native";/**@@ -8,55 +9,37 @@ import { setCurrentNativeViewId, useNativeCompositorView } from "@/native";* le compositing ; le `<div>` ne sert qu'à donner sa géométrie (le hook sync le* rect natif au resize/scroll).*- * F3 : avant de créer la vue, on résout les vraies sources de l'enregistrement- * (screen + webcam, deux fichiers H264 séparés) via la session courante, pour que- * le natif compose TON clip et pas la fixture. Session absente (projet rechargé,- * web pur) → fallback fixture. Enregistrement sans caméra → webcam fixture (le- * compositeur compose toujours une webcam ; le no-webcam viendra avec les presets).+ * F3 : les sources natives (screen + webcam) sont résolues depuis l'**asset primaire+ * du document courant** — donc ce que l'éditeur affiche réellement. (On lisait avant+ * `getCurrentRecordingSession()` = le dernier *enregistré*, qui pouvait pointer sur un+ * ancien clip → on voyait « l'ancien clip » sous le blur.) Pas d'asset / pas de doc →+ * fallback fixture. Le hook recrée la vue si le chemin screen change (changement de projet).*- * Aucun contrôle ici : les paramètres viennent de l'inspector (barre latérale) via- * le store `nativeCompositorStore` (`setNativeParam`), la lecture via- * `useNativePlaybackSync`, l'export via la vraie modale (`ExportDialog`).+ * Aucun contrôle ici : paramètres via l'inspector (`setNativeParam`), lecture via+ * `useNativePlaybackSync`, export via la vraie modale (`ExportDialog`).** Opt-in via le flag Vite `VITE_NATIVE_COMPOSITOR=1`.*/export function NativeCompositorOverlay({ enabled }: { enabled: boolean }) {const mountRef = useRef<HTMLDivElement>(null);- // `null` = résolution en cours ; `{}` = résolu sans session (→ fixture) ;- // `{screenPath,…}` = vraies sources. On attend la résolution avant de créer la- // vue (sources lues une fois à la création) pour éviter un re-create fixture→réel.- const [sources, setSources] = useState<{- screenPath?: string;- webcamPath?: string;- } | null>(null);+ const document = useProjectStore((s) => s.document);- useEffect(() => {- if (!enabled) {- return;+ // `null` = document pas encore chargé (on attend) ; `{}` = chargé sans asset (→ fixture) ;+ // `{screenPath,…}` = vraies sources de l'asset primaire.+ const sources = useMemo(() => {+ if (!document) {+ return null;+ }+ const primary =+ document.assets.find((a) => a.id === document.project.primaryAssetId) ?? document.assets[0];+ if (!primary?.originalPath) {+ return {};}- let cancelled = false;- void (async () => {- try {- const result = await window.electronAPI?.getCurrentRecordingSession?.();- if (cancelled) {- return;- }- const session = result?.success ? result.session : null;- setSources(- session?.screenVideoPath- ? { screenPath: session.screenVideoPath, webcamPath: session.webcamVideoPath }- : {},- );- } catch {- if (!cancelled) {- setSources({});- }- }- })();- return () => {- cancelled = true;+ return {+ screenPath: primary.originalPath,+ webcamPath: primary.cameraTrack?.sourcePath ?? undefined,};- }, [enabled]);+ }, [document]);const ready = sources !== null;const { viewId } = useNativeCompositorView(mountRef, {diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsxindex 382834ec6..b97e9c7c9 100644--- a/src/components/ai-edition/RightPanes.tsx+++ b/src/components/ai-edition/RightPanes.tsx@@ -1211,7 +1211,10 @@ export function VideoEffectsPane() {// The onChange handlers above already push per-control diffs; this effect// also covers the "user tweaked a setting before the native view was// mounted" case so the view doesn't render with stale defaults.- const ROUNDNESS_MAX = 64;+ // Le rayon natif = rayon de base de la fixture (~24px @1920) × cette échelle. Diviser la+ // valeur px de l'UI par ce même rayon de base fait que le coin natif ≈ les px affichés+ // (au lieu de plafonner à ~24px comme avec /64).+ const NATIVE_SCREEN_BASE_RADIUS_PX = 24;useEffect(() => {const syncToNative = () => {// pas de garde `isNativeCompositorActive` : setNativeParam mémorise les valeurs@@ -1220,7 +1223,7 @@ export function VideoEffectsPane() {setNativeParam("backgroundBlur", settings.showBlur);setNativeParam("motionBlur", settings.motionBlurAmount);setNativeParam("shadow", settings.shadowIntensity);- setNativeParam("roundness", settings.borderRadius / ROUNDNESS_MAX);+ setNativeParam("roundness", settings.borderRadius / NATIVE_SCREEN_BASE_RADIUS_PX);setNativeParam("padding", settings.padding / 100);const bg = settings.wallpaper;if (bg.startsWith("#")) {@@ -1299,7 +1302,7 @@ export function VideoEffectsPane() {onChange={(v) => {setLive({ borderRadius: v });if (isNativeCompositorActive()) {- setNativeParam("roundness", v / ROUNDNESS_MAX);+ setNativeParam("roundness", v / NATIVE_SCREEN_BASE_RADIUS_PX);}}}onCommit={() => void commit()}diff --git a/src/native/compositorViewClient.ts b/src/native/compositorViewClient.tsindex 10865180f..c7d05d1aa 100644--- a/src/native/compositorViewClient.ts+++ b/src/native/compositorViewClient.ts@@ -8,6 +8,7 @@import { requireNativeBridgeData } from "./client";import type {+ CompositorClipInput,CompositorExportResult,CompositorParamValue,CompositorViewRect,@@ -76,3 +77,14 @@ export function exportNative(outPath?: string): Promise<CompositorExportResult>payload: { outPath },});}++export function exportMultiNative(+ clips: CompositorClipInput[],+ outPath?: string,+): Promise<CompositorExportResult> {+ return requireNativeBridgeData<CompositorExportResult>({+ domain: "compositor",+ action: "exportMulti",+ payload: { clips, outPath },+ });+}diff --git a/src/native/contracts.ts b/src/native/contracts.tsindex a0c569a1c..53cfb4c9c 100644--- a/src/native/contracts.ts+++ b/src/native/contracts.ts@@ -113,6 +113,16 @@ export interface CompositorViewResult {id: number;}+/** Un clip de la timeline pour l'export multiclip natif (fichiers screen+webcam + trim). */+export interface CompositorClipInput {+ screenPath: string;+ webcamPath: string;+ sourceStartSec: number;+ sourceEndSec: number;+ /** temps source webcam = temps source screen − ceci. */+ webcamOffsetSec: number;+}+/** Bilan d'un export natif (mesure enveloppante §10 : frames, durée, fps). */export interface CompositorExportResult {frames: number;@@ -660,6 +670,12 @@ export type NativeBridgeRequest =payload: { outPath?: string };requestId?: string;}+ | {+ domain: "compositor";+ action: "exportMulti";+ payload: { clips: CompositorClipInput[]; outPath?: string };+ requestId?: string;+ }| {domain: "compositor";action: "presentTime";diff --git a/src/native/hooks/useNativeCompositorView.ts b/src/native/hooks/useNativeCompositorView.tsindex 146070de2..481996efa 100644--- a/src/native/hooks/useNativeCompositorView.ts+++ b/src/native/hooks/useNativeCompositorView.ts@@ -61,6 +61,9 @@ export function useNativeCompositorView(opts: UseNativeCompositorViewOptions = {},): UseNativeCompositorViewResult {const enabled = opts.enabled !== false;+ // Re-create the native view when the screen source changes (e.g. loading a different+ // project) so it never keeps showing a stale clip.+ const screenPath = opts.sources?.screenPath;const [viewId, setViewId] = useState<number | null>(null);// Mirror into a ref so async callbacks always see the freshest id without// re-subscribing the main effect.@@ -142,9 +145,9 @@ export function useNativeCompositorView(safelyCall("destroyView", () => destroyCompositorView(id));}};- // `ref` is a stable RefObject; we only re-run the effect when- // the enabled flag flips.- }, [enabled, ref]);+ // `ref` is a stable RefObject; we re-run (destroy + re-create the view) when the+ // enabled flag flips or the screen source changes.+ }, [enabled, ref, screenPath]);const setParam = useCallback((key: string, value: CompositorParamValue) => {const id = viewIdRef.current;