Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Improve export stability and progress handling
Richie McIlroy3cab306f4510
diff --git a/apps/cli/src/main.rs b/apps/cli/src/main.rsindex 90b205a12..7ddded8b0 100644--- a/apps/cli/src/main.rs+++ b/apps/cli/src/main.rs@@ -14,7 +14,9 @@ use record::RecordStart;use serde::{Deserialize, Serialize};use serde_json::json;use tracing::*;-use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};+use tracing_subscriber::{filter::LevelFilter, layer::SubscriberExt, util::SubscriberInitExt};++const TOKIO_WORKER_THREAD_STACK_SIZE: usize = 16 * 1024 * 1024;#[derive(Parser)]struct Cli {@@ -32,6 +34,12 @@ enum Commands {Record(RecordArgs),}+impl Commands {+ fn exit_after_success(&self) -> bool {+ matches!(self, Self::Export(_) | Self::ExportPreview(_))+ }+}+#[derive(Args)]#[command(args_conflicts_with_subcommands = true)]// #[command(flatten_help = true)]@@ -54,16 +62,22 @@ enum RecordCommands {// Mics,}-#[tokio::main]-async fn main() -> Result<(), String> {+fn main() -> Result<(), String> {// let (layer, handle) = tracing_subscriber::reload::Layer::new(None::<DynLoggingLayer>);+ let level_filter = if cfg!(debug_assertions) {+ LevelFilter::TRACE+ } else {+ LevelFilter::WARN+ };+let registry = tracing_subscriber::registry().with(tracing_subscriber::filter::filter_fn((|v| v.target().starts_with("cap_")) as fn(&tracing::Metadata) -> bool,));registry// .with(layer)+ .with(level_filter).with(tracing_subscriber::fmt::layer().with_ansi(true)@@ -73,7 +87,39 @@ async fn main() -> Result<(), String> {.init();let cli = Cli::parse();+ let exit_after_success = cli.command.exit_after_success();++ // Windows export exercises deep WGPU/MediaFoundation/FFmpeg stacks. Running the CLI runtime+ // on an explicitly large stack is what stopped the export worker from overflowing before+ // the first frame; keep the sidecar and desktop runtimes in sync.+ std::thread::Builder::new()+ .name("cap-cli-runtime".to_string())+ .stack_size(TOKIO_WORKER_THREAD_STACK_SIZE)+ .spawn(move || {+ let runtime = tokio::runtime::Builder::new_multi_thread()+ .enable_all()+ .thread_stack_size(TOKIO_WORKER_THREAD_STACK_SIZE)+ .build()+ .map_err(|e| format!("Failed to build Tokio runtime: {e}"))?;++ let result = runtime.block_on(run(cli));+ if exit_after_success && result.is_ok() {+ // Successful export/preview workers have already written their output by here.+ // Exiting directly avoids Windows GPU/MediaFoundation teardown crashes in the+ // short-lived sidecar process.+ let _ = stdout().flush();+ let _ = stderr().flush();+ std::process::exit(0);+ }+ result+ })+ .map_err(|e| format!("Failed to spawn CLI runtime thread: {e}"))?+ .join()+ .map_err(|_| "CLI runtime thread panicked".to_string())?+}++async fn run(cli: Cli) -> Result<(), String> {match cli.command {Commands::Export(e) => {e.run().await?;@@ -165,6 +211,8 @@ struct Export {force_ffmpeg_decoder: bool,#[arg(long)]progress_json: bool,+ #[arg(long)]+ completion_json: bool,}#[derive(Args)]@@ -264,6 +312,7 @@ impl Export {let total_frames = exporter_base.total_frames(settings.fps());let progress_json = self.progress_json;+ let completion_json = self.completion_json;let stdout = Arc::new(Mutex::new(stdout()));if progress_json {@@ -299,7 +348,7 @@ impl Export {}.map_err(|v| format!("Exporter error: {v}"))?;- if self.progress_json {+ if progress_json || completion_json {emit_export_message(&stdout,&ExportProgressMessage::Completed { path: &output_path },diff --git a/apps/desktop/src-tauri/src/export.rs b/apps/desktop/src-tauri/src/export.rsindex 46f0a3558..e3fc3b30e 100644--- a/apps/desktop/src-tauri/src/export.rs+++ b/apps/desktop/src-tauri/src/export.rs@@ -62,6 +62,7 @@ async fn run_protected_export(const EXPORTER_ENV_BIN_PATH: &str = "CAP_EXPORTER_BIN";const EXPORTER_STDERR_TAIL_LIMIT: usize = 80;+const EXPORT_PROGRESS_FORWARD_INTERVAL: std::time::Duration = std::time::Duration::from_millis(100);static ACTIVE_EXPORT_SESSIONS: AtomicUsize = AtomicUsize::new(0);#[cfg(windows)]@@ -79,6 +80,22 @@ enum ExportSidecarMessage {},}+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+enum ExportWorkerMode {+ HardwareOptimized,+ SoftwareSafe,+}++impl ExportWorkerMode {+ fn force_ffmpeg_decoder(self, requested: bool) -> bool {+ requested || matches!(self, Self::SoftwareSafe)+ }++ fn is_software_safe(self) -> bool {+ matches!(self, Self::SoftwareSafe)+ }+}+#[derive(Clone)]enum ExportProgress {Channel(tauri::ipc::Channel<FramesRendered>),@@ -98,6 +115,47 @@ impl ExportProgress {}}+struct ExportProgressForwarder {+ progress: ExportProgress,+ last_emit_at: Option<std::time::Instant>,+}++impl ExportProgressForwarder {+ fn new(progress: ExportProgress) -> Self {+ Self {+ progress,+ last_emit_at: None,+ }+ }++ fn enabled(&self) -> bool {+ self.progress.enabled()+ }++ fn send(&mut self, rendered_count: u32, total_frames: u32) -> bool {+ if !self.progress.enabled() {+ return true;+ }++ let now = std::time::Instant::now();+ let should_emit = rendered_count == 0+ || rendered_count >= total_frames+ || self+ .last_emit_at+ .is_none_or(|last| now.duration_since(last) >= EXPORT_PROGRESS_FORWARD_INTERVAL);++ if !should_emit {+ return true;+ }++ self.last_emit_at = Some(now);+ self.progress.send(FramesRendered {+ rendered_count,+ total_frames,+ })+ }+}+fn retain_export_session() {let active_exports = ACTIVE_EXPORT_SESSIONS.fetch_add(1, Ordering::AcqRel) + 1;info!(active_exports, "Export session guard started");@@ -174,24 +232,33 @@ async fn run_out_of_process_export(progress: ExportProgress,force_ffmpeg: bool,) -> Result<PathBuf, String> {- let safe_mode = should_start_export_sidecar_in_safe_mode();+ let mode = ExportWorkerMode::HardwareOptimized;+ // Windows GPU drivers, MediaFoundation, and encoder DLLs can abort the process on failure.+ // Keep the first fast hardware attempt in the worker, then retry in software-safe mode so+ // the desktop process never owns the crash-prone export pipeline.match run_out_of_process_export_attempt(project_path,settings,progress.clone(),force_ffmpeg,- safe_mode,+ mode,).await{Ok(path) => Ok(path),- Err(e) if e != "Export cancelled" && !safe_mode => {+ Err(e) if e != "Export cancelled" => {error!(error = %e,"Export worker failed, retrying with software rendering and encoding");- run_out_of_process_export_attempt(project_path, settings, progress, force_ffmpeg, true)- .await+ run_out_of_process_export_attempt(+ project_path,+ settings,+ progress,+ force_ffmpeg,+ ExportWorkerMode::SoftwareSafe,+ )+ .await}Err(e) => Err(e),}@@ -202,17 +269,19 @@ async fn run_out_of_process_export_attempt(settings: &ExportSettings,progress: ExportProgress,force_ffmpeg: bool,- safe_mode: bool,+ mode: ExportWorkerMode,) -> Result<PathBuf, String> {let bin_path = resolve_exporter_binary()?;let settings_json = serde_json::to_string(settings).map_err(|e| format!("Failed to serialize settings: {e}"))?;+ let force_ffmpeg_decoder = mode.force_ffmpeg_decoder(force_ffmpeg);+ let mut progress_forwarder = ExportProgressForwarder::new(progress);info!(path = %bin_path.display(),project_path = %project_path.display(),- force_ffmpeg,- safe_mode,+ force_ffmpeg = force_ffmpeg_decoder,+ mode = ?mode,"Starting export worker process");@@ -222,16 +291,21 @@ async fn run_out_of_process_export_attempt(.arg(project_path).arg("--settings-json").arg(settings_json)- .arg("--progress-json").stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::piped());- if force_ffmpeg {+ if progress_forwarder.enabled() {+ command.arg("--progress-json");+ } else {+ command.arg("--completion-json");+ }++ if force_ffmpeg_decoder {command.arg("--force-ffmpeg-decoder");}- if safe_mode {+ if mode.is_software_safe() {command.env("CAP_RENDER_FORCE_SOFTWARE_ADAPTER", "1").env("CAP_EXPORT_FORCE_SOFTWARE_ENCODER", "1");@@ -268,10 +342,7 @@ async fn run_out_of_process_export_attempt(rendered_count,total_frames,}) => {- if !progress.send(FramesRendered {- rendered_count,- total_frames,- }) {+ if !progress_forwarder.send(rendered_count, total_frames) {let _ = child.kill().await;return Err("Export cancelled".to_string());}@@ -296,6 +367,18 @@ async fn run_out_of_process_export_attempt(let stderr_tail = stderr_task.await.unwrap_or_default();if !status.success() {+ if let Some(path) = completed_path {+ // A worker can report completion and then abort during Windows GPU/codec teardown.+ // Treat the completed output as authoritative so a post-export sidecar crash does+ // not become a failed export for the user.+ error!(+ status = %status,+ path = %path.display(),+ "Export worker exited unsuccessfully after reporting completion"+ );+ return Ok(path);+ }+let stderr_tail = stderr_tail.join("\n");return Err(format!("Export worker exited with status {status}. Stderr tail:\n{stderr_tail}"@@ -313,7 +396,9 @@ async fn collect_exporter_stderr_tail(stderr: tokio::process::ChildStderr) -> Veloop {match lines.next_line().await {Ok(Some(line)) => {- info!(line = %line, "Export worker stderr");+ if cfg!(debug_assertions) {+ info!(line = %line, "Export worker stderr");+ }tail.push(line);if tail.len() > EXPORTER_STDERR_TAIL_LIMIT {tail.remove(0);@@ -344,6 +429,15 @@ fn resolve_exporter_binary() -> Result<PathBuf, String> {let exe = std::env::current_exe().map_err(|e| format!("current_exe: {e}"))?;if let Some(dir) = exe.parent() {+ // In dev, `cap.exe` is the binary Cargo rebuilds; stale `cap-exporter.exe` copies were+ // the reason desktop exports lagged behind the fast CLI path during this fix.+ if cfg!(debug_assertions) {+ let candidate = dir.join(cli_bin_name());+ if candidate.exists() {+ return Ok(candidate);+ }+ }+let candidate = dir.join(exporter_bin_name());if candidate.exists() {return Ok(candidate);@@ -356,12 +450,11 @@ fn resolve_exporter_binary() -> Result<PathBuf, String> {}if let Ok(cwd) = std::env::current_dir() {- for candidate in [- cwd.join("target").join("debug").join(cli_bin_name()),- cwd.join("target").join("release").join(cli_bin_name()),- ] {- if candidate.exists() {- return Ok(candidate);+ for root in std::iter::once(cwd.as_path()).chain(cwd.ancestors()) {+ for candidate in exporter_binary_candidates(root) {+ if candidate.exists() {+ return Ok(candidate);+ }}}}@@ -372,6 +465,59 @@ fn resolve_exporter_binary() -> Result<PathBuf, String> {))}+fn exporter_binary_candidates(root: &Path) -> Vec<PathBuf> {+ let mut candidates = vec![+ root.join("target").join("debug").join(cli_bin_name()),+ root.join("target").join("release").join(cli_bin_name()),+ root.join("apps")+ .join("desktop")+ .join("src-tauri")+ .join("binaries")+ .join(exporter_bin_name()),+ ];++ if let Some(target_triple) = current_target_triple() {+ candidates.extend([+ root.join("target")+ .join(target_triple)+ .join("debug")+ .join(cli_bin_name()),+ root.join("target")+ .join(target_triple)+ .join("release")+ .join(cli_bin_name()),+ root.join("apps")+ .join("desktop")+ .join("src-tauri")+ .join("binaries")+ .join(format!(+ "cap-exporter-{target_triple}{}",+ std::env::consts::EXE_SUFFIX+ )),+ ]);+ }++ candidates+}++fn current_target_triple() -> Option<&'static str> {+ if cfg!(all(+ target_os = "windows",+ target_arch = "x86_64",+ target_env = "msvc"+ )) {+ Some("x86_64-pc-windows-msvc")+ } else if cfg!(all(+ target_os = "windows",+ target_arch = "aarch64",+ target_env = "msvc"+ )) {+ Some("aarch64-pc-windows-msvc")+ } else {+ None+ }+}+fn exporter_bin_name() -> &'static str {if cfg!(windows) {"cap-exporter.exe"@@ -526,7 +672,7 @@ fn is_frame_decode_error(error: &str) -> bool {}fn should_force_ffmpeg_export(_project_path: &Path, settings: &ExportSettings) -> bool {- settings.force_ffmpeg_decoder() || should_use_windows_release_ffmpeg_workaround()+ settings.force_ffmpeg_decoder()}fn should_force_ffmpeg_preview() -> bool {@@ -534,15 +680,7 @@ fn should_force_ffmpeg_preview() -> bool {}fn should_use_out_of_process_export() -> bool {- should_use_release_export_sidecar()-}--fn should_use_release_export_sidecar() -> bool {- cfg!(all(target_os = "macos", not(debug_assertions)))-}--fn should_start_export_sidecar_in_safe_mode() -> bool {- cfg!(all(target_os = "windows", not(debug_assertions)))+ cfg!(any(target_os = "macos", target_os = "windows"))}fn should_use_windows_release_ffmpeg_workaround() -> bool {diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rsindex 4de5aa7b6..4ea22d80d 100644--- a/apps/desktop/src-tauri/src/main.rs+++ b/apps/desktop/src-tauri/src/main.rs@@ -6,6 +6,8 @@ use std::sync::Arc;use cap_desktop_lib::DynLoggingLayer;use tracing_subscriber::{Layer, layer::SubscriberExt, util::SubscriberInitExt};+const TOKIO_WORKER_THREAD_STACK_SIZE: usize = 16 * 1024 * 1024;+fn main() {#[cfg(debug_assertions)]unsafe {@@ -151,6 +153,7 @@ fn main() {tokio::runtime::Builder::new_multi_thread().enable_all()+ .thread_stack_size(TOKIO_WORKER_THREAD_STACK_SIZE).build().expect("Failed to build multi threaded tokio runtime").block_on(cap_desktop_lib::run(handle, logs_dir));diff --git a/apps/desktop/src-tauri/src/web_api.rs b/apps/desktop/src-tauri/src/web_api.rsindex 7bd522040..e0e4ec6d2 100644--- a/apps/desktop/src-tauri/src/web_api.rs+++ b/apps/desktop/src-tauri/src/web_api.rs@@ -133,7 +133,7 @@ impl<T: Manager<R> + Emitter<R>, R: Runtime> ManagerExt<R> for T {let path = path.into();let server_url = current_server_url(self).await?;- let url = format!("{}{}", server_url, path);+ let url = format!("{server_url}{path}");let response =do_authed_request(&self.state::<http_client::HttpClient>(), &auth, build, url).await?;@@ -160,7 +160,7 @@ impl<T: Manager<R> + Emitter<R>, R: Runtime> ManagerExt<R> for T {async fn make_app_url(&self, pathname: impl AsRef<str>) -> String {let pathname = pathname.as_ref();match current_server_url(self).await {- Ok(server_url) => format!("{}{}", server_url, pathname),+ Ok(server_url) => format!("{server_url}{pathname}"),Err(err) => {warn!("App state unavailable while building app URL: {err}");format!("{}{}", default_server_url(), pathname)diff --git a/apps/desktop/src-tauri/src/windows.rs b/apps/desktop/src-tauri/src/windows.rsindex 66ab21277..fb916f767 100644--- a/apps/desktop/src-tauri/src/windows.rs+++ b/apps/desktop/src-tauri/src/windows.rs@@ -1526,8 +1526,7 @@ impl ShowCapWindow {.transparent(true).visible(false).initialization_script(format!(- "window.__CAP__ = window.__CAP__ ?? {{}}; window.__CAP__.cameraWsPort = {};",- camera_ws_port+ "window.__CAP__ = window.__CAP__ ?? {{}}; window.__CAP__.cameraWsPort = {camera_ws_port};"));#[cfg(target_os = "macos")]@@ -2511,8 +2510,7 @@ impl ShowCapWindow {let bg_color = if is_dark { "#141414" } else { "#ffffff" };let init_script = format!(- r#"(function(){{var s=document.createElement('style');s.textContent='html,body{{background-color:{bg}}}';document.documentElement.appendChild(s);}})();"#,- bg = bg_color+ r#"(function(){{var s=document.createElement('style');s.textContent='html,body{{background-color:{bg_color}}}';document.documentElement.appendChild(s);}})();"#);builder = builder.initialization_script(&init_script);}diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex e0c1904d9..b57a57099 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -92,9 +92,21 @@ async focusCapturesPanel() : Promise<void> {async getCurrentRecording() : Promise<JsonValue<CurrentRecording | null>> {return await TAURI_INVOKE("get_current_recording");},+async beginExportSession() : Promise<void> {+ await TAURI_INVOKE("begin_export_session");+},+async endExportSession() : Promise<void> {+ await TAURI_INVOKE("end_export_session");+},async exportVideo(projectPath: string, progress: TAURI_CHANNEL<FramesRendered>, settings: ExportSettings) : Promise<string> {return await TAURI_INVOKE("export_video", { projectPath, progress, settings });},+async exportVideoNoProgress(projectPath: string, settings: ExportSettings) : Promise<string> {+ return await TAURI_INVOKE("export_video_no_progress", { projectPath, settings });+},+async exportVideoNoProgressDetached(projectPath: string, settingsJson: string) : Promise<string> {+ return await TAURI_INVOKE("export_video_no_progress_detached", { projectPath, settingsJson });+},async getExportEstimates(path: string, settings: ExportSettings) : Promise<ExportEstimates> {return await TAURI_INVOKE("get_export_estimates", { path, settings });},@@ -194,6 +206,9 @@ async createScreenshotEditorInstance() : Promise<SerializedScreenshotEditorInstaasync updateScreenshotConfig(config: ProjectConfiguration, save: boolean, revision: number) : Promise<null> {return await TAURI_INVOKE("update_screenshot_config", { config, save, revision });},+async recognizeScreenshotText(region: ScreenshotOcrRegion) : Promise<ScreenshotOcrResult> {+ return await TAURI_INVOKE("recognize_screenshot_text", { region });+},async getRecordingMeta(path: string, fileType: FileType) : Promise<RecordingMetaWithMetadata> {return await TAURI_INVOKE("get_recording_meta", { path, fileType });},@@ -590,6 +605,9 @@ export type SceneMode = "default" | "cameraOnly" | "hideCamera"export type SceneSegment = { start: number; end: number; mode?: SceneMode }export type ScreenCaptureTarget = { variant: "window"; id: WindowId } | { variant: "display"; id: DisplayId } | { variant: "area"; screen: DisplayId; bounds: LogicalBounds } | { variant: "cameraOnly" }export type ScreenMovementSpring = { stiffness: number; damping: number; mass: number }+export type ScreenshotOcrLine = { text: string; confidence: number | null; bounds: ScreenshotOcrRegion }+export type ScreenshotOcrRegion = { x: number; y: number; width: number; height: number }+export type ScreenshotOcrResult = { text: string; lines: ScreenshotOcrLine[]; engine: string }export type SegmentRecordings = { display: Video; camera: Video | null; mic: Audio | null; system_audio: Audio | null }export type SerializedEditorInstance = { framesSocketUrl: string; recordingDuration: number; savedProjectConfig: ProjectConfiguration; recordings: ProjectRecordingsMeta; path: string }export type SerializedScreenshotEditorInstance = { framesSocketUrl: string; path: string; config: ProjectConfiguration | null; prettyName: string; imageWidth: number; imageHeight: number }diff --git a/crates/enc-ffmpeg/src/video/h264.rs b/crates/enc-ffmpeg/src/video/h264.rsindex 6a863dc86..7f844ee35 100644--- a/crates/enc-ffmpeg/src/video/h264.rs+++ b/crates/enc-ffmpeg/src/video/h264.rs@@ -900,7 +900,7 @@ fn export_encoder_priority_override(use cap_frame_converter::{GpuVendor, detect_primary_gpu};static ENCODER_PRIORITY_AMD_EXPORT: &[&str] =- &["h264_mf", "h264_amf", "h264_nvenc", "h264_qsv", "libx264"];+ &["h264_amf", "h264_mf", "h264_nvenc", "h264_qsv", "libx264"];if let Some(GpuVendor::Amd) = detect_primary_gpu().map(|info| info.vendor) {return Some(ENCODER_PRIORITY_AMD_EXPORT);diff --git a/crates/recording/src/output_pipeline/oop_muxer.rs b/crates/recording/src/output_pipeline/oop_muxer.rsindex de82e7e96..9a5675afd 100644--- a/crates/recording/src/output_pipeline/oop_muxer.rs+++ b/crates/recording/src/output_pipeline/oop_muxer.rs@@ -4,6 +4,8 @@ use cap_muxer_protocol::{Frame, InitAudio, InitVideo, PACKET_FLAG_KEYFRAME, Packet, STREAM_INDEX_AUDIO,STREAM_INDEX_VIDEO, StartParams, write_frame,};+#[cfg(windows)]+use std::os::windows::process::CommandExt;use std::{collections::VecDeque,io::{BufWriter, Write},@@ -24,6 +26,9 @@ const RESPAWN_COOLDOWN: Duration = Duration::from_millis(500);const RESPAWN_STABILITY_WINDOW: Duration = Duration::from_secs(5);pub const EXIT_DISK_FULL: u8 = 60;+#[cfg(windows)]+const CREATE_NO_WINDOW: u32 = 0x0800_0000;+static MUXER_BINARY_OVERRIDE: OnceLock<PathBuf> = OnceLock::new();pub fn set_muxer_binary_override(path: PathBuf) -> Result<(), PathBuf> {@@ -167,18 +172,20 @@ impl MuxerSubprocess {config: MuxerSubprocessConfig,health_tx: Option<HealthSender>,) -> Result<Self, MuxerSubprocessError> {- let mut child = Command::new(&bin_path)+ let mut command = Command::new(&bin_path);+ command.stdin(Stdio::piped()).stdout(Stdio::null()).stderr(Stdio::piped()).env("CAP_MUXER_LOG",std::env::var("CAP_MUXER_LOG").unwrap_or_else(|_| "info".to_string()),- )- .spawn()- .map_err(|e| {- MuxerSubprocessError::Spawn(anyhow!("failed to spawn {}: {e}", bin_path.display()))- })?;+ );+ configure_muxer_command(&mut command);++ let mut child = command.spawn().map_err(|e| {+ MuxerSubprocessError::Spawn(anyhow!("failed to spawn {}: {e}", bin_path.display()))+ })?;let stdin = child.stdin@@ -543,6 +550,14 @@ impl Drop for MuxerSubprocess {}}+#[cfg(windows)]+fn configure_muxer_command(command: &mut Command) {+ command.creation_flags(CREATE_NO_WINDOW);+}++#[cfg(not(windows))]+fn configure_muxer_command(_command: &mut Command) {}+#[derive(Debug)]pub struct MuxerSubprocessReport {pub packets_written: u64,diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rsindex 8c9cb4fa6..b79db1557 100644--- a/crates/rendering/src/lib.rs+++ b/crates/rendering/src/lib.rs@@ -1462,15 +1462,18 @@ pub fn get_duration(&& let Ok(camera_duration) =recordings.get_source_duration(&recording_meta.path(&camera_path)){- println!("Camera recording duration: {camera_duration}");max_duration = max_duration.max(camera_duration);- println!("New max duration after camera check: {max_duration}");+ tracing::debug!(+ camera_duration,+ max_duration,+ "Adjusted project duration using camera recording"+ );}if let Some(timeline) = &project.timeline {timeline.duration()} else {- println!("No timeline found, using max_duration: {max_duration}");+ tracing::debug!(max_duration, "Using recording duration without timeline");max_duration}}