Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
wip: Synthetic recording benchmarks
Richie McIlroy8ab5c58db9ef
diff --git a/.claude/settings.local.json b/.claude/settings.local.jsonindex f0e207bf2..b565856ee 100644--- a/.claude/settings.local.json+++ b/.claude/settings.local.json@@ -54,7 +54,11 @@"Bash(./target/release/examples/decode-benchmark:*)","Bash(RUST_LOG=warn ./target/release/examples/decode-benchmark:*)","Bash(git mv:*)",- "Bash(xargs cat:*)"+ "Bash(xargs cat:*)",+ "Bash(cargo test:*)",+ "Bash(/opt/homebrew/bin/ffmpeg:*)",+ "Bash(RUST_LOG=info cargo run:*)",+ "Bash(RUST_LOG=warn cargo run:*)"],"deny": [],"ask": []diff --git a/Cargo.lock b/Cargo.lockindex 90a9a5dd1..592885436 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1531,6 +1531,7 @@ dependencies = ["cap-utils","chrono","cidre",+ "clap","cocoa","core-foundation 0.10.1","core-graphics 0.24.0",diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.tsindex b41da5c46..18ba0fbe6 100644--- a/apps/desktop/src/utils/tauri.ts+++ b/apps/desktop/src/utils/tauri.ts@@ -364,7 +364,6 @@ uploadProgressEvent: "upload-progress-event"/** user-defined types **/-export type AllGpusInfo = { gpus: GpuInfoDiag[]; primaryGpuIndex: number | null; isMultiGpuSystem: boolean; hasDiscreteGpu: boolean }export type Annotation = { id: string; type: AnnotationType; x: number; y: number; width: number; height: number; strokeColor: string; strokeWidth: number; fillColor: string; opacity: number; rotation: number; text: string | null; maskType?: MaskType | null; maskLevel?: number | null }export type AnnotationType = "arrow" | "circle" | "rectangle" | "text" | "mask"export type AppTheme = "system" | "light" | "dark"@@ -432,7 +431,6 @@ quality: number | null;* Whether to prioritize speed over quality (default: false)*/fast: boolean | null }-export type GpuInfoDiag = { vendor: string; description: string; dedicatedVideoMemoryMb: number; adapterIndex: number; isSoftwareAdapter: boolean; isBasicRenderDriver: boolean; supportsHardwareEncoding: boolean }export type HapticPattern = "alignment" | "levelChange" | "generic"export type HapticPerformanceTime = "default" | "now" | "drawCompleted"export type Hotkey = { code: string; meta: boolean; ctrl: boolean; alt: boolean; shift: boolean }@@ -445,6 +443,7 @@ export type JsonValue<T> = [T]export type LogicalBounds = { position: LogicalPosition; size: LogicalSize }export type LogicalPosition = { x: number; y: number }export type LogicalSize = { width: number; height: number }+export type MacOSVersionInfo = { displayName: string }export type MainWindowRecordingStartBehaviour = "close" | "minimise"export type MaskKeyframes = { position?: MaskVectorKeyframe[]; size?: MaskVectorKeyframe[]; intensity?: MaskScalarKeyframe[] }export type MaskKind = "sensitive" | "highlight"@@ -487,7 +486,6 @@ export type RecordingStatus = "pending" | "recording"export type RecordingStopped = nullexport type RecordingTargetMode = "display" | "window" | "area"export type RenderFrameEvent = { frame_number: number; fps: number; resolution_base: XY<number> }-export type RenderingStatus = { isUsingSoftwareRendering: boolean; isUsingBasicRenderDriver: boolean; hardwareEncodingAvailable: boolean; warningMessage: string | null }export type RequestOpenRecordingPicker = { target_mode: RecordingTargetMode | null }export type RequestOpenSettings = { page: string }export type RequestScreenCapturePrewarm = { force?: boolean }@@ -508,7 +506,7 @@ export type StartRecordingInputs = { capture_target: ScreenCaptureTarget; capturexport type StereoMode = "stereo" | "monoL" | "monoR"export type StudioRecordingMeta = { segment: SingleSegment } | { inner: MultipleSegments }export type StudioRecordingStatus = { status: "InProgress" } | { status: "NeedsRemux" } | { status: "Failed"; error: string } | { status: "Complete" }-export type SystemDiagnostics = { windowsVersion: WindowsVersionInfo | null; gpuInfo: GpuInfoDiag | null; allGpus: AllGpusInfo | null; renderingStatus: RenderingStatus; availableEncoders: string[]; graphicsCaptureSupported: boolean; d3D11VideoProcessorAvailable: boolean }+export type SystemDiagnostics = { macosVersion: MacOSVersionInfo | null; availableEncoders: string[]; screenCaptureSupported: boolean }export type TargetUnderCursor = { display_id: DisplayId | null; window: WindowUnderCursor | null }export type TextSegment = { start: number; end: number; enabled?: boolean; content?: string; center?: XY<number>; size?: XY<number>; fontFamily?: string; fontSize?: number; fontWeight?: number; italic?: boolean; color?: string; fadeDuration?: number }export type TimelineConfiguration = { segments: TimelineSegment[]; zoomSegments: ZoomSegment[]; sceneSegments?: SceneSegment[]; maskSegments?: MaskSegment[]; textSegments?: TextSegment[] }@@ -525,7 +523,6 @@ export type VideoUploadInfo = { id: string; link: string; config: S3UploadMeta }export type WindowExclusion = { bundleIdentifier?: string | null; ownerName?: string | null; windowTitle?: string | null }export type WindowId = stringexport type WindowUnderCursor = { id: WindowId; app_name: string; bounds: LogicalBounds }-export type WindowsVersionInfo = { major: number; minor: number; build: number; displayName: string; meetsRequirements: boolean; isWindows11: boolean }export type XY<T> = { x: T; y: T }export type ZoomMode = "auto" | { manual: { x: number; y: number } }export type ZoomSegment = { start: number; end: number; amount: number; mode: ZoomMode }diff --git a/crates/enc-ffmpeg/src/mux/segmented_stream.rs b/crates/enc-ffmpeg/src/mux/segmented_stream.rsindex 0ab253b0a..a4a6e4882 100644--- a/crates/enc-ffmpeg/src/mux/segmented_stream.rs+++ b/crates/enc-ffmpeg/src/mux/segmented_stream.rs@@ -148,19 +148,6 @@ impl SegmentedVideoEncoder {let mut output = format::output_as(&manifest_path, "dash")?;- let init_seg_path = base_path.join(INIT_SEGMENT_NAME);- let media_seg_pattern = base_path.join("segment_$Number%03d$.m4s");-- #[cfg(windows)]- let init_seg_str = init_seg_path.to_string_lossy().replace('\\', "/");- #[cfg(windows)]- let media_seg_str = media_seg_pattern.to_string_lossy().replace('\\', "/");-- #[cfg(not(windows))]- let init_seg_str = init_seg_path.to_string_lossy().to_string();- #[cfg(not(windows))]- let media_seg_str = media_seg_pattern.to_string_lossy().to_string();-unsafe {let opts = output.as_mut_ptr();@@ -170,8 +157,8 @@ impl SegmentedVideoEncoder {ffmpeg::ffi::av_opt_set((*opts).priv_data, k.as_ptr(), v.as_ptr(), 0);};- set_opt("init_seg_name", &init_seg_str);- set_opt("media_seg_name", &media_seg_str);+ set_opt("init_seg_name", INIT_SEGMENT_NAME);+ set_opt("media_seg_name", "segment_$Number%03d$.m4s");set_opt("seg_duration",&config.segment_duration.as_secs_f64().to_string(),@@ -179,6 +166,7 @@ impl SegmentedVideoEncoder {set_opt("use_timeline", "0");set_opt("use_template", "1");set_opt("single_file", "0");+ set_opt("hls_playlist", "1");}let mut builder = H264EncoderBuilder::new(video_config)diff --git a/crates/enc-ffmpeg/src/video/h264.rs b/crates/enc-ffmpeg/src/video/h264.rsindex bd566f2e3..47cef1adc 100644--- a/crates/enc-ffmpeg/src/video/h264.rs+++ b/crates/enc-ffmpeg/src/video/h264.rs@@ -4,6 +4,7 @@ use cap_media_info::{Pixel, VideoInfo};use ffmpeg::{Dictionary,codec::{codec::Codec, context, encoder},+ color,format::{self},frame,threading::Config,@@ -274,6 +275,14 @@ impl H264EncoderBuilder {encoder.set_format(output_format);encoder.set_time_base(input_config.time_base);encoder.set_frame_rate(Some(input_config.frame_rate));+ encoder.set_colorspace(color::Space::BT709);+ encoder.set_color_range(color::Range::MPEG);+ unsafe {+ (*encoder.as_mut_ptr()).color_primaries =+ ffmpeg::ffi::AVColorPrimaries::AVCOL_PRI_BT709;+ (*encoder.as_mut_ptr()).color_trc =+ ffmpeg::ffi::AVColorTransferCharacteristic::AVCOL_TRC_BT709;+ }let bitrate = get_bitrate(output_width,@@ -514,6 +523,7 @@ fn get_codec_and_options(match *encoder_name {"h264_videotoolbox" => {options.set("realtime", "true");+ options.set("prio_speed", "true");}"h264_nvenc" => {options.set("preset", "p4");diff --git a/crates/enc-ffmpeg/src/video/hevc.rs b/crates/enc-ffmpeg/src/video/hevc.rsindex 0f9e24ca9..14284e580 100644--- a/crates/enc-ffmpeg/src/video/hevc.rs+++ b/crates/enc-ffmpeg/src/video/hevc.rs@@ -4,6 +4,7 @@ use cap_media_info::{Pixel, VideoInfo};use ffmpeg::{Dictionary,codec::{codec::Codec, context, encoder},+ color,format::{self},frame,threading::Config,@@ -239,6 +240,14 @@ impl HevcEncoderBuilder {encoder.set_format(output_format);encoder.set_time_base(input_config.time_base);encoder.set_frame_rate(Some(input_config.frame_rate));+ encoder.set_colorspace(color::Space::BT709);+ encoder.set_color_range(color::Range::MPEG);+ unsafe {+ (*encoder.as_mut_ptr()).color_primaries =+ ffmpeg::ffi::AVColorPrimaries::AVCOL_PRI_BT709;+ (*encoder.as_mut_ptr()).color_trc =+ ffmpeg::ffi::AVColorTransferCharacteristic::AVCOL_TRC_BT709;+ }let bitrate = get_bitrate(output_width,@@ -449,6 +458,8 @@ fn get_codec_and_options(match *encoder_name {"hevc_videotoolbox" => {options.set("realtime", "true");+ options.set("prio_speed", "true");+ options.set("max_ref_frames", "1");}"hevc_nvenc" => {options.set("preset", "p4");diff --git a/crates/recording/Cargo.toml b/crates/recording/Cargo.tomlindex 409c19cb0..6d395e96a 100644--- a/crates/recording/Cargo.toml+++ b/crates/recording/Cargo.toml@@ -6,6 +6,10 @@ edition = "2024"[lints]workspace = true+[features]+default = []+test-utils = []+[dependencies]cap-audio = { path = "../audio" }cap-fail = { path = "../fail" }@@ -88,6 +92,12 @@ scap-cpal = { path = "../scap-cpal" }[dev-dependencies]tempfile = "3.20.0"tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }+clap = { version = "4.5", features = ["derive"] }+tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }[target.'cfg(target_os = "macos")'.dev-dependencies]libproc = "0.14"++[[example]]+name = "synthetic-test-runner"+required-features = ["test-utils"]diff --git a/crates/recording/examples/synthetic-test-runner.rs b/crates/recording/examples/synthetic-test-runner.rsnew file mode 100644index 000000000..1d8ca5267--- /dev/null+++ b/crates/recording/examples/synthetic-test-runner.rs@@ -0,0 +1,875 @@+use cap_recording::{+ Mp4Muxer, OggMuxer, OutputPipeline, SegmentedVideoMuxer, SegmentedVideoMuxerConfig,+ test_sources::{+ AudioGenerator, AudioTestConfig, OutputFormat, RecordingValidator, SyntheticAudioSource,+ SyntheticAudioSourceConfig, TestConfig, TestPattern, TestPatternVideoSource,+ TestPatternVideoSourceConfig, ValidationConfig, VideoTestConfig, common_test_configs,+ comprehensive_test_configs,+ },+};+use cap_timestamp::Timestamps;+use clap::{Parser, Subcommand};+use std::{+ path::PathBuf,+ time::{Duration, Instant},+};+use tokio_util::sync::CancellationToken;+use tracing_subscriber::{EnvFilter, fmt, prelude::*};++#[derive(Parser)]+#[command(name = "synthetic-test-runner")]+#[command(about = "Run synthetic recording tests without physical hardware")]+struct Cli {+ #[command(subcommand)]+ command: Option<Commands>,++ #[arg(long, default_value = "5")]+ duration: u64,++ #[arg(long)]+ report: Option<PathBuf>,++ #[arg(long)]+ keep_outputs: bool,++ #[arg(long, default_value = "/tmp/cap-synthetic-tests")]+ output_dir: PathBuf,+}++#[derive(Subcommand)]+enum Commands {+ Quick,+ Full,+ StudioMode,+ Resolution {+ #[arg(long)]+ width: u32,+ #[arg(long)]+ height: u32,+ #[arg(long, default_value = "30")]+ fps: u32,+ },+ Source {+ #[arg(value_enum)]+ source_type: SourceType,+ },+ List,+ Sync {+ #[arg(long, default_value = "50")]+ tolerance_ms: f64,+ },+}++#[derive(Clone, Copy, clap::ValueEnum)]+enum SourceType {+ Screen,+ Camera,+ Microphone,+}++#[tokio::main]+async fn main() {+ tracing_subscriber::registry()+ .with(fmt::layer())+ .with(EnvFilter::from_default_env().add_directive(tracing::Level::INFO.into()))+ .init();++ let cli = Cli::parse();++ let duration = Duration::from_secs(cli.duration);++ let configs = match &cli.command {+ None | Some(Commands::Quick) => {+ println!("Running quick test suite (~10 common configurations)...\n");+ common_test_configs()+ }+ Some(Commands::Full) => {+ println!("Running full test suite (comprehensive matrix)...\n");+ comprehensive_test_configs()+ }+ Some(Commands::StudioMode) => {+ println!("Running Studio Mode simulation (screen + camera + mic)...\n");+ vec![create_studio_mode_config(duration)]+ }+ Some(Commands::Resolution { width, height, fps }) => {+ println!("Testing resolution {}x{} @ {}fps...\n", width, height, fps);+ vec![TestConfig {+ video: Some(+ VideoTestConfig::default()+ .with_resolution(*width, *height)+ .with_frame_rate(*fps),+ ),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ }]+ }+ Some(Commands::Source { source_type }) => match source_type {+ SourceType::Screen => {+ println!("Testing screen capture configurations...\n");+ screen_test_configs(duration)+ }+ SourceType::Camera => {+ println!("Testing webcam configurations...\n");+ camera_test_configs(duration)+ }+ SourceType::Microphone => {+ println!("Testing microphone configurations...\n");+ microphone_test_configs(duration)+ }+ },+ Some(Commands::List) => {+ list_test_configurations();+ return;+ }+ Some(Commands::Sync { tolerance_ms }) => {+ println!(+ "Running A/V sync verification tests (tolerance: {}ms)...\n",+ tolerance_ms+ );+ sync_test_configs(duration, *tolerance_ms)+ }+ };++ let total_tests = configs.len();+ let mut passed = 0;+ let mut failed = 0;+ let mut results = Vec::new();++ let start = Instant::now();++ for (idx, config) in configs.iter().enumerate() {+ let test_name = format_test_name(config);+ println!("[{}/{}] {}", idx + 1, total_tests, test_name);++ let result = run_synthetic_test(config, &cli.output_dir, idx).await;++ match &result {+ TestResult::Passed {+ validation,+ elapsed,+ } => {+ passed += 1;+ println!(+ " \u{2713} Frame count: {}/{}",+ validation.actual_frames, validation.expected_frames+ );+ println!(+ " \u{2713} A/V sync: {:.1}ms offset (< 50ms threshold)",+ validation.av_sync_offset_ms+ );+ if validation.fragments_checked > 0 {+ println!(+ " \u{2713} Fragment integrity: {} segments OK",+ validation.fragments_valid+ );+ }+ println!(" Duration: {:.2}s\n", elapsed.as_secs_f64());+ }+ TestResult::Failed { error, elapsed } => {+ failed += 1;+ println!(" \u{2717} FAILED: {}", error);+ println!(" Duration: {:.2}s\n", elapsed.as_secs_f64());+ }+ TestResult::Skipped { reason } => {+ println!(" - SKIPPED: {}\n", reason);+ }+ }++ results.push((test_name, result));+ }++ let total_elapsed = start.elapsed();++ println!("\n{}", "=".repeat(60));+ println!(+ "Summary: {}/{} passed, {} failed",+ passed, total_tests, failed+ );+ println!("Total time: {:.1}s", total_elapsed.as_secs_f64());++ if failed > 0 {+ println!("\nFailed tests:");+ for (name, result) in &results {+ if let TestResult::Failed { error, .. } = result {+ println!(" - {}: {}", name, error);+ }+ }+ }++ if let Some(report_path) = &cli.report {+ save_report(report_path, &results);+ println!("\nReport saved to: {}", report_path.display());+ }++ if !cli.keep_outputs {+ if let Err(e) = std::fs::remove_dir_all(&cli.output_dir) {+ tracing::warn!("Failed to clean up output directory: {}", e);+ }+ }++ std::process::exit(if failed > 0 { 1 } else { 0 });+}++#[allow(dead_code)]+enum TestResult {+ Passed {+ validation: cap_recording::test_sources::ValidationResult,+ elapsed: Duration,+ },+ Failed {+ error: String,+ elapsed: Duration,+ },+ Skipped {+ reason: String,+ },+}++async fn run_synthetic_test(+ config: &TestConfig,+ output_dir: &PathBuf,+ test_idx: usize,+) -> TestResult {+ let start = Instant::now();++ let test_output_dir = output_dir.join(format!("test_{}", test_idx));+ if let Err(e) = std::fs::create_dir_all(&test_output_dir) {+ return TestResult::Failed {+ error: format!("Failed to create output directory: {}", e),+ elapsed: start.elapsed(),+ };+ }++ let timestamps = Timestamps::now();+ let cancel_token = CancellationToken::new();++ let output_path = match &config.output_format {+ OutputFormat::Mp4 => test_output_dir.join("output.mp4"),+ OutputFormat::FragmentedM4s { .. } => test_output_dir.join("segments"),+ OutputFormat::OggOpus => test_output_dir.join("output.ogg"),+ };++ let pipeline_result = match (&config.video, &config.audio, &config.output_format) {+ (Some(video_config), Some(audio_config), OutputFormat::Mp4) => {+ run_mp4_recording(+ &output_path,+ video_config,+ audio_config,+ config.duration,+ timestamps,+ cancel_token.clone(),+ )+ .await+ }+ (Some(video_config), None, OutputFormat::Mp4) => {+ run_video_only_mp4_recording(+ &output_path,+ video_config,+ config.duration,+ timestamps,+ cancel_token.clone(),+ )+ .await+ }+ (None, Some(audio_config), OutputFormat::OggOpus) => {+ run_audio_only_ogg_recording(+ &output_path,+ audio_config,+ config.duration,+ timestamps,+ cancel_token.clone(),+ )+ .await+ }+ (+ Some(video_config),+ Some(audio_config),+ OutputFormat::FragmentedM4s { segment_duration },+ ) => {+ run_segmented_m4s_recording(+ &output_path,+ video_config,+ audio_config,+ config.duration,+ *segment_duration,+ timestamps,+ cancel_token.clone(),+ )+ .await+ }+ (Some(video_config), None, OutputFormat::FragmentedM4s { segment_duration }) => {+ run_video_only_segmented_m4s_recording(+ &output_path,+ video_config,+ config.duration,+ *segment_duration,+ timestamps,+ cancel_token.clone(),+ )+ .await+ }+ _ => {+ return TestResult::Skipped {+ reason: "Unsupported configuration combination".to_string(),+ };+ }+ };++ let elapsed = start.elapsed();++ match pipeline_result {+ Ok(()) => {+ let validator = RecordingValidator::new(config).with_config(ValidationConfig {+ frame_count_tolerance: 0.10,+ duration_tolerance: Duration::from_millis(1000),+ av_sync_tolerance_ms: 50.0,+ check_fragments: true,+ });++ let validation_result = match &config.output_format {+ OutputFormat::FragmentedM4s { .. } => {+ validator.validate_m4s_fragments(&output_path).await+ }+ _ => validator.validate_mp4(&output_path).await,+ };++ match validation_result {+ Ok(validation) => {+ if validation.is_valid() {+ TestResult::Passed {+ validation,+ elapsed,+ }+ } else {+ let mut failures = vec![];+ if !validation.frame_count_ok {+ failures.push(format!(+ "frame_count: {}/{}",+ validation.actual_frames, validation.expected_frames+ ));+ }+ if !validation.duration_ok {+ failures.push(format!(+ "duration: {:.2}s/{:.2}s",+ validation.actual_duration.as_secs_f64(),+ validation.expected_duration.as_secs_f64()+ ));+ }+ if !validation.av_sync_ok {+ failures.push(format!(+ "av_sync: {:.1}ms offset",+ validation.av_sync_offset_ms+ ));+ }+ if !validation.fragment_integrity {+ failures.push(format!(+ "fragments: {}/{}",+ validation.fragments_valid, validation.fragments_checked+ ));+ }+ if !validation.errors.is_empty() {+ failures.push(validation.errors.join(", "));+ }+ TestResult::Failed {+ error: format!("Validation failed: {}", failures.join("; ")),+ elapsed,+ }+ }+ }+ Err(e) => TestResult::Failed {+ error: format!("Validation error: {}", e),+ elapsed,+ },+ }+ }+ Err(e) => TestResult::Failed {+ error: format!("Recording failed: {}", e),+ elapsed,+ },+ }+}++async fn run_mp4_recording(+ output_path: &std::path::Path,+ video_config: &VideoTestConfig,+ audio_config: &AudioTestConfig,+ duration: Duration,+ timestamps: Timestamps,+ cancel_token: CancellationToken,+) -> anyhow::Result<()> {+ let video_source_config = TestPatternVideoSourceConfig {+ video_config: video_config.clone(),+ duration,+ timestamps,+ cancel_token: cancel_token.clone(),+ };++ let audio_source_config = SyntheticAudioSourceConfig {+ audio_config: audio_config.clone(),+ duration,+ timestamps,+ cancel_token: cancel_token.clone(),+ };++ let pipeline = OutputPipeline::builder(output_path.to_path_buf())+ .with_timestamps(timestamps)+ .with_video::<TestPatternVideoSource>(video_source_config)+ .with_audio_source::<SyntheticAudioSource>(audio_source_config)+ .build::<Mp4Muxer>(())+ .await?;++ tokio::time::sleep(duration + Duration::from_millis(500)).await;++ pipeline.stop().await?;++ Ok(())+}++async fn run_video_only_mp4_recording(+ output_path: &std::path::Path,+ video_config: &VideoTestConfig,+ duration: Duration,+ timestamps: Timestamps,+ cancel_token: CancellationToken,+) -> anyhow::Result<()> {+ let video_source_config = TestPatternVideoSourceConfig {+ video_config: video_config.clone(),+ duration,+ timestamps,+ cancel_token: cancel_token.clone(),+ };++ let pipeline = OutputPipeline::builder(output_path.to_path_buf())+ .with_timestamps(timestamps)+ .with_video::<TestPatternVideoSource>(video_source_config)+ .build::<Mp4Muxer>(())+ .await?;++ tokio::time::sleep(duration + Duration::from_millis(500)).await;++ pipeline.stop().await?;++ Ok(())+}++async fn run_audio_only_ogg_recording(+ output_path: &std::path::Path,+ audio_config: &AudioTestConfig,+ duration: Duration,+ timestamps: Timestamps,+ cancel_token: CancellationToken,+) -> anyhow::Result<()> {+ let audio_source_config = SyntheticAudioSourceConfig {+ audio_config: audio_config.clone(),+ duration,+ timestamps,+ cancel_token: cancel_token.clone(),+ };++ let pipeline = OutputPipeline::builder(output_path.to_path_buf())+ .with_timestamps(timestamps)+ .with_audio_source::<SyntheticAudioSource>(audio_source_config)+ .build::<OggMuxer>(())+ .await?;++ tokio::time::sleep(duration + Duration::from_millis(500)).await;++ pipeline.stop().await?;++ Ok(())+}++async fn run_segmented_m4s_recording(+ output_path: &std::path::Path,+ video_config: &VideoTestConfig,+ _audio_config: &AudioTestConfig,+ duration: Duration,+ segment_duration: Duration,+ timestamps: Timestamps,+ cancel_token: CancellationToken,+) -> anyhow::Result<()> {+ let video_source_config = TestPatternVideoSourceConfig {+ video_config: video_config.clone(),+ duration,+ timestamps,+ cancel_token: cancel_token.clone(),+ };++ let muxer_config = SegmentedVideoMuxerConfig {+ segment_duration,+ ..Default::default()+ };++ let pipeline = OutputPipeline::builder(output_path.to_path_buf())+ .with_timestamps(timestamps)+ .with_video::<TestPatternVideoSource>(video_source_config)+ .build::<SegmentedVideoMuxer>(muxer_config)+ .await?;++ tokio::time::sleep(duration + Duration::from_millis(500)).await;++ pipeline.stop().await?;++ Ok(())+}++async fn run_video_only_segmented_m4s_recording(+ output_path: &std::path::Path,+ video_config: &VideoTestConfig,+ duration: Duration,+ segment_duration: Duration,+ timestamps: Timestamps,+ cancel_token: CancellationToken,+) -> anyhow::Result<()> {+ let video_source_config = TestPatternVideoSourceConfig {+ video_config: video_config.clone(),+ duration,+ timestamps,+ cancel_token: cancel_token.clone(),+ };++ let muxer_config = SegmentedVideoMuxerConfig {+ segment_duration,+ ..Default::default()+ };++ let pipeline = OutputPipeline::builder(output_path.to_path_buf())+ .with_timestamps(timestamps)+ .with_video::<TestPatternVideoSource>(video_source_config)+ .build::<SegmentedVideoMuxer>(muxer_config)+ .await?;++ tokio::time::sleep(duration + Duration::from_millis(500)).await;++ pipeline.stop().await?;++ Ok(())+}++fn format_test_name(config: &TestConfig) -> String {+ let mut parts = vec![];++ if let Some(video) = &config.video {+ parts.push(format!(+ "{}x{}@{}fps",+ video.width, video.height, video.frame_rate+ ));+ parts.push(format!("{:?}", video.pixel_format));+ }++ if let Some(audio) = &config.audio {+ parts.push(format!("{}kHz", audio.sample_rate / 1000));+ if audio.channels == 1 {+ parts.push("mono".to_string());+ } else if audio.channels == 2 {+ parts.push("stereo".to_string());+ } else {+ parts.push(format!("{}ch", audio.channels));+ }+ }++ parts.join(" + ")+}++fn create_studio_mode_config(duration: Duration) -> TestConfig {+ TestConfig {+ video: Some(+ VideoTestConfig::fhd_1080p()+ .with_frame_rate(60)+ .with_pattern(TestPattern::FrameCounter),+ ),+ audio: Some(AudioTestConfig::broadcast_stereo().with_generator(+ AudioGenerator::TimestampBeeps {+ beep_interval_ms: 1000,+ },+ )),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ }+}++fn screen_test_configs(duration: Duration) -> Vec<TestConfig> {+ vec![+ TestConfig {+ video: Some(VideoTestConfig::hd_720p()),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ TestConfig {+ video: Some(VideoTestConfig::fhd_1080p()),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ TestConfig {+ video: Some(VideoTestConfig::fhd_1080p().with_frame_rate(60)),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ TestConfig {+ video: Some(VideoTestConfig::qhd_1440p()),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ TestConfig {+ video: Some(VideoTestConfig::uhd_4k()),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ TestConfig {+ video: Some(VideoTestConfig::ultrawide_1080()),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ TestConfig {+ video: Some(VideoTestConfig::macbook_retina()),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ TestConfig {+ video: Some(VideoTestConfig::portrait_1080()),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ ]+}++fn camera_test_configs(duration: Duration) -> Vec<TestConfig> {+ vec![+ TestConfig {+ video: Some(VideoTestConfig::webcam_vga()),+ audio: None,+ duration,+ output_format: OutputFormat::Mp4,+ },+ TestConfig {+ video: Some(VideoTestConfig::webcam_hd()),+ audio: None,+ duration,+ output_format: OutputFormat::Mp4,+ },+ TestConfig {+ video: Some(VideoTestConfig::webcam_hd().with_frame_rate(60)),+ audio: None,+ duration,+ output_format: OutputFormat::Mp4,+ },+ TestConfig {+ video: Some(VideoTestConfig::webcam_fhd()),+ audio: None,+ duration,+ output_format: OutputFormat::Mp4,+ },+ TestConfig {+ video: Some(VideoTestConfig::webcam_4k()),+ audio: None,+ duration,+ output_format: OutputFormat::Mp4,+ },+ ]+}++fn microphone_test_configs(duration: Duration) -> Vec<TestConfig> {+ vec![+ TestConfig {+ video: None,+ audio: Some(AudioTestConfig::cd_quality_mono()),+ duration,+ output_format: OutputFormat::OggOpus,+ },+ TestConfig {+ video: None,+ audio: Some(AudioTestConfig::cd_quality_stereo()),+ duration,+ output_format: OutputFormat::OggOpus,+ },+ TestConfig {+ video: None,+ audio: Some(AudioTestConfig::broadcast_mono()),+ duration,+ output_format: OutputFormat::OggOpus,+ },+ TestConfig {+ video: None,+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration,+ output_format: OutputFormat::OggOpus,+ },+ TestConfig {+ video: None,+ audio: Some(AudioTestConfig::high_res_stereo()),+ duration,+ output_format: OutputFormat::OggOpus,+ },+ TestConfig {+ video: None,+ audio: Some(AudioTestConfig::voice_optimized()),+ duration,+ output_format: OutputFormat::OggOpus,+ },+ ]+}++fn sync_test_configs(duration: Duration, _tolerance_ms: f64) -> Vec<TestConfig> {+ vec![+ TestConfig {+ video: Some(+ VideoTestConfig::fhd_1080p()+ .with_frame_rate(30)+ .with_pattern(TestPattern::TimestampOverlay),+ ),+ audio: Some(AudioTestConfig::broadcast_stereo().with_generator(+ AudioGenerator::TimestampBeeps {+ beep_interval_ms: 1000,+ },+ )),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ TestConfig {+ video: Some(+ VideoTestConfig::fhd_1080p()+ .with_frame_rate(60)+ .with_pattern(TestPattern::TimestampOverlay),+ ),+ audio: Some(AudioTestConfig::broadcast_stereo().with_generator(+ AudioGenerator::TimestampBeeps {+ beep_interval_ms: 1000,+ },+ )),+ duration,+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ ]+}++fn list_test_configurations() {+ println!("Available test configurations:\n");++ println!("Screen Capture Simulations (--source screen):");+ println!(" - 720p (1280x720)");+ println!(" - 1080p (1920x1080) @ 30/60fps");+ println!(" - 1440p (2560x1440)");+ println!(" - 4K (3840x2160)");+ println!(" - Ultrawide (2560x1080, 3440x1440)");+ println!(" - Portrait (1080x1920)");+ println!(" - MacBook Retina (2880x1800)");+ println!(" - MacBook Pro 14\" (3024x1964)");+ println!(" - MacBook Pro 16\" ProMotion (3456x2234 @ 120fps)");+ println!();++ println!("Webcam Simulations (--source camera):");+ println!(" - VGA (640x480)");+ println!(" - HD (1280x720) @ 30/60fps");+ println!(" - FHD (1920x1080) @ 30/60fps");+ println!(" - 4K (3840x2160)");+ println!();++ println!("Microphone Simulations (--source microphone):");+ println!(" - CD Quality (44.1kHz mono/stereo)");+ println!(" - Broadcast (48kHz mono/stereo)");+ println!(" - High-res (96kHz stereo)");+ println!(" - Voice-optimized (16kHz mono S16)");+ println!();++ println!("Output Formats:");+ println!(" - Fragmented M4S (default, 3s segments)");+ println!(" - MP4 (single file)");+ println!(" - OGG Opus (audio-only)");+ println!();++ println!("Commands:");+ println!(" quick - Run ~10 common configurations (~1 min)");+ println!(" full - Run full test matrix (~30 min)");+ println!(" studio-mode - Screen + camera + mic combined");+ println!(" resolution - Test specific resolution (--width --height --fps)");+ println!(" source - Test specific source type (screen/camera/microphone)");+ println!(" sync - A/V sync verification tests");+ println!(" list - Show this help");+}++fn save_report(path: &PathBuf, results: &[(String, TestResult)]) {+ let mut report = String::new();++ report.push_str("{\n \"results\": [\n");++ for (idx, (name, result)) in results.iter().enumerate() {+ let status = match result {+ TestResult::Passed { .. } => "passed",+ TestResult::Failed { .. } => "failed",+ TestResult::Skipped { .. } => "skipped",+ };++ let details = match result {+ TestResult::Passed {+ validation,+ elapsed,+ } => {+ format!(+ r#""frames": {}, "duration_secs": {:.2}, "sync_offset_ms": {:.1}"#,+ validation.actual_frames,+ elapsed.as_secs_f64(),+ validation.av_sync_offset_ms+ )+ }+ TestResult::Failed { error, elapsed } => {+ format!(+ r#""error": "{}", "duration_secs": {:.2}"#,+ error.replace('"', "\\\""),+ elapsed.as_secs_f64()+ )+ }+ TestResult::Skipped { reason } => {+ format!(r#""reason": "{}""#, reason.replace('"', "\\\""))+ }+ };++ report.push_str(&format!(+ " {{ \"name\": \"{}\", \"status\": \"{}\", {} }}",+ name, status, details+ ));++ if idx < results.len() - 1 {+ report.push(',');+ }+ report.push('\n');+ }++ report.push_str(" ]\n}\n");++ if let Err(e) = std::fs::write(path, &report) {+ tracing::error!("Failed to write report: {}", e);+ }+}diff --git a/crates/recording/run-synthetic-tests.sh b/crates/recording/run-synthetic-tests.shnew file mode 100755index 000000000..b19b6fa06--- /dev/null+++ b/crates/recording/run-synthetic-tests.sh@@ -0,0 +1,2 @@+#!/bin/bash+cargo run --package cap-recording --example synthetic-test-runner --features test-utils -- "$@"diff --git a/crates/recording/src/lib.rs b/crates/recording/src/lib.rsindex dc1670b27..965c70920 100644--- a/crates/recording/src/lib.rs+++ b/crates/recording/src/lib.rs@@ -11,6 +11,9 @@ pub mod screenshot;pub mod sources;pub mod studio_recording;+#[cfg(any(test, feature = "test-utils"))]+pub mod test_sources;+pub use feeds::{camera::CameraFeed, microphone::MicrophoneFeed};pub use output_pipeline::*;pub use sources::screen_capture;diff --git a/crates/recording/src/output_pipeline/ffmpeg.rs b/crates/recording/src/output_pipeline/ffmpeg.rsindex 8e9439331..7f6e9a4f6 100644--- a/crates/recording/src/output_pipeline/ffmpeg.rs+++ b/crates/recording/src/output_pipeline/ffmpeg.rs@@ -4,16 +4,27 @@ use crate::{};use anyhow::{Context, anyhow};use cap_enc_ffmpeg::{- aac::AACEncoder, fragmented_audio::FragmentedAudioFile, h264::*, ogg::*, opus::OpusEncoder,+ aac::AACEncoder,+ fragmented_audio::FragmentedAudioFile,+ h264::*,+ ogg::*,+ opus::OpusEncoder,segmented_audio::SegmentedAudioEncoder,+ segmented_stream::{SegmentedVideoEncoder, SegmentedVideoEncoderConfig},};use cap_media_info::{AudioInfo, VideoInfo};use cap_timestamp::Timestamp;use std::{path::PathBuf,- sync::{Arc, atomic::AtomicBool},+ sync::{+ Arc, Mutex,+ atomic::AtomicBool,+ mpsc::{SyncSender, sync_channel},+ },+ thread::JoinHandle,time::Duration,};+use tracing::*;#[derive(Clone)]pub struct FFmpegVideoFrame {@@ -268,3 +279,375 @@ impl AudioMuxer for SegmentedAudioMuxer {.map_err(|e| anyhow!("Failed to queue audio frame: {e}"))}}++fn get_muxer_buffer_size() -> usize {+ std::env::var("CAP_MUXER_BUFFER_SIZE")+ .ok()+ .and_then(|s| s.parse().ok())+ .unwrap_or(30)+}++struct FrameDropTracker {+ drops_in_window: u32,+ frames_in_window: u32,+ total_drops: u64,+ total_frames: u64,+ last_check: std::time::Instant,+}++impl FrameDropTracker {+ fn new() -> Self {+ Self {+ drops_in_window: 0,+ frames_in_window: 0,+ total_drops: 0,+ total_frames: 0,+ last_check: std::time::Instant::now(),+ }+ }++ fn record_frame(&mut self) {+ self.frames_in_window += 1;+ self.total_frames += 1;+ self.check_drop_rate();+ }++ fn record_drop(&mut self) {+ self.drops_in_window += 1;+ self.total_drops += 1;+ self.check_drop_rate();+ }++ fn check_drop_rate(&mut self) {+ if self.last_check.elapsed() >= Duration::from_secs(5) {+ let total_in_window = self.frames_in_window + self.drops_in_window;+ if total_in_window > 0 {+ let drop_rate = 100.0 * self.drops_in_window as f64 / total_in_window as f64;+ if drop_rate > 5.0 {+ warn!(+ frames = self.frames_in_window,+ drops = self.drops_in_window,+ drop_rate_pct = format!("{:.1}%", drop_rate),+ total_frames = self.total_frames,+ total_drops = self.total_drops,+ "Segmented muxer frame drop rate exceeds 5% threshold"+ );+ } else if self.drops_in_window > 0 {+ debug!(+ frames = self.frames_in_window,+ drops = self.drops_in_window,+ drop_rate_pct = format!("{:.1}%", drop_rate),+ "Segmented muxer frame stats"+ );+ }+ }+ self.drops_in_window = 0;+ self.frames_in_window = 0;+ self.last_check = std::time::Instant::now();+ }+ }++ fn report_final_stats(&self) {+ let total = self.total_frames + self.total_drops;+ if total == 0 {+ return;+ }++ let drop_rate = 100.0 * self.total_drops as f64 / total as f64;++ if self.total_drops > 0 {+ if drop_rate > 5.0 {+ warn!(+ total_frames = self.total_frames,+ total_drops = self.total_drops,+ drop_rate_pct = format!("{:.1}%", drop_rate),+ "Recording finished with significant frame drops"+ );+ } else {+ info!(+ total_frames = self.total_frames,+ total_drops = self.total_drops,+ drop_rate_pct = format!("{:.1}%", drop_rate),+ "Recording finished with minor frame drops"+ );+ }+ } else {+ debug!(+ total_frames = self.total_frames,+ "Recording finished with no frame drops"+ );+ }+ }+}++struct SegmentedEncoderState {+ video_tx: SyncSender<Option<(ffmpeg::frame::Video, Duration)>>,+ encoder: Arc<Mutex<SegmentedVideoEncoder>>,+ encoder_handle: Option<JoinHandle<anyhow::Result<()>>>,+}++pub struct SegmentedVideoMuxer {+ base_path: PathBuf,+ video_config: VideoInfo,+ segment_duration: Duration,+ preset: H264Preset,+ output_size: Option<(u32, u32)>,+ state: Option<SegmentedEncoderState>,+ pause: SharedPauseState,+ frame_drops: FrameDropTracker,+ started: bool,+}++pub struct SegmentedVideoMuxerConfig {+ pub segment_duration: Duration,+ pub preset: H264Preset,+ pub output_size: Option<(u32, u32)>,+ pub shared_pause_state: Option<SharedPauseState>,+}++impl Default for SegmentedVideoMuxerConfig {+ fn default() -> Self {+ Self {+ segment_duration: Duration::from_secs(3),+ preset: H264Preset::Ultrafast,+ output_size: None,+ shared_pause_state: None,+ }+ }+}++impl Muxer for SegmentedVideoMuxer {+ type Config = SegmentedVideoMuxerConfig;++ async fn setup(+ config: Self::Config,+ output_path: PathBuf,+ video_config: Option<VideoInfo>,+ _audio_config: Option<AudioInfo>,+ pause_flag: Arc<AtomicBool>,+ _tasks: &mut TaskPool,+ ) -> anyhow::Result<Self>+ where+ Self: Sized,+ {+ let video_config =+ video_config.ok_or_else(|| anyhow!("invariant: video config expected"))?;++ std::fs::create_dir_all(&output_path)+ .with_context(|| format!("Failed to create segments directory: {output_path:?}"))?;++ let pause = config+ .shared_pause_state+ .unwrap_or_else(|| SharedPauseState::new(pause_flag));++ Ok(Self {+ base_path: output_path,+ video_config,+ segment_duration: config.segment_duration,+ preset: config.preset,+ output_size: config.output_size,+ state: None,+ pause,+ frame_drops: FrameDropTracker::new(),+ started: false,+ })+ }++ fn stop(&mut self) {+ if let Some(state) = &self.state+ && let Err(e) = state.video_tx.send(None)+ {+ trace!("Segmented encoder channel already closed during stop: {e}");+ }+ }++ fn finish(&mut self, timestamp: Duration) -> anyhow::Result<anyhow::Result<()>> {+ if let Some(mut state) = self.state.take() {+ if let Err(e) = state.video_tx.send(None) {+ trace!("Segmented encoder channel already closed during finish: {e}");+ }++ if let Some(handle) = state.encoder_handle.take() {+ let timeout = Duration::from_secs(5);+ let start = std::time::Instant::now();+ loop {+ if handle.is_finished() {+ match handle.join() {+ Err(panic_payload) => {+ warn!(+ "Segmented encoder thread panicked during finish: {:?}",+ panic_payload+ );+ }+ Ok(Err(e)) => {+ warn!("Segmented encoder thread returned error: {e}");+ }+ Ok(Ok(())) => {}+ }+ break;+ }+ if start.elapsed() > timeout {+ warn!(+ "Segmented encoder thread did not finish within {:?}, abandoning",+ timeout+ );+ break;+ }+ std::thread::sleep(Duration::from_millis(50));+ }+ }++ if let Ok(mut encoder) = state.encoder.lock()+ && let Err(e) = encoder.finish_with_timestamp(timestamp)+ {+ warn!("Failed to finish segmented encoder: {e}");+ }+ }++ self.frame_drops.report_final_stats();++ Ok(Ok(()))+ }+}++impl SegmentedVideoMuxer {+ fn start_encoder(&mut self) -> anyhow::Result<()> {+ let buffer_size = get_muxer_buffer_size();+ debug!(+ buffer_size = buffer_size,+ "Segmented muxer encoder channel buffer size"+ );++ let (video_tx, video_rx) =+ sync_channel::<Option<(ffmpeg::frame::Video, Duration)>>(buffer_size);+ let (ready_tx, ready_rx) = sync_channel::<anyhow::Result<()>>(1);++ let encoder_config = SegmentedVideoEncoderConfig {+ segment_duration: self.segment_duration,+ preset: self.preset,+ bpp: H264EncoderBuilder::QUALITY_BPP,+ output_size: self.output_size,+ };++ let encoder =+ SegmentedVideoEncoder::init(self.base_path.clone(), self.video_config, encoder_config)?;+ let encoder = Arc::new(Mutex::new(encoder));+ let encoder_clone = encoder.clone();++ let encoder_handle = std::thread::Builder::new()+ .name("segmented-video-encoder".to_string())+ .spawn(move || {+ if ready_tx.send(Ok(())).is_err() {+ return Err(anyhow!("Failed to send ready signal - receiver dropped"));+ }++ let mut slow_encode_count = 0u32;+ let mut total_frames = 0u64;+ const SLOW_THRESHOLD_MS: u128 = 5;++ while let Ok(Some((frame, timestamp))) = video_rx.recv() {+ let encode_start = std::time::Instant::now();++ if let Ok(mut encoder) = encoder_clone.lock()+ && let Err(e) = encoder.queue_frame(frame, timestamp)+ {+ warn!("Failed to encode frame: {e}");+ }++ let encode_elapsed_ms = encode_start.elapsed().as_millis();++ if encode_elapsed_ms > SLOW_THRESHOLD_MS {+ slow_encode_count += 1;+ if slow_encode_count <= 5 || slow_encode_count.is_multiple_of(100) {+ debug!(+ elapsed_ms = encode_elapsed_ms,+ count = slow_encode_count,+ "encoder.queue_frame exceeded {}ms threshold",+ SLOW_THRESHOLD_MS+ );+ }+ }++ total_frames += 1;+ }++ if total_frames > 0 {+ debug!(+ total_frames = total_frames,+ slow_encodes = slow_encode_count,+ slow_encode_pct = format!(+ "{:.1}%",+ 100.0 * slow_encode_count as f64 / total_frames as f64+ ),+ "Segmented encoder timing summary"+ );+ }++ Ok(())+ })?;++ ready_rx+ .recv()+ .map_err(|_| anyhow!("Segmented encoder thread ended unexpectedly"))??;++ self.state = Some(SegmentedEncoderState {+ video_tx,+ encoder,+ encoder_handle: Some(encoder_handle),+ });++ self.started = true;++ info!(+ path = %self.base_path.display(),+ "Started segmented video encoder"+ );++ Ok(())+ }+}++impl VideoMuxer for SegmentedVideoMuxer {+ type VideoFrame = FFmpegVideoFrame;++ fn send_video_frame(+ &mut self,+ frame: Self::VideoFrame,+ timestamp: Duration,+ ) -> anyhow::Result<()> {+ let Some(adjusted_timestamp) = self.pause.adjust(timestamp)? else {+ return Ok(());+ };++ if !self.started {+ self.start_encoder()?;+ }++ if let Some(state) = &self.state {+ match state+ .video_tx+ .try_send(Some((frame.inner, adjusted_timestamp)))+ {+ Ok(()) => {+ self.frame_drops.record_frame();+ }+ Err(e) => match e {+ std::sync::mpsc::TrySendError::Full(_) => {+ self.frame_drops.record_drop();+ }+ std::sync::mpsc::TrySendError::Disconnected(_) => {+ trace!("Segmented encoder channel disconnected");+ }+ },+ }+ }++ Ok(())+ }+}++impl AudioMuxer for SegmentedVideoMuxer {+ fn send_audio_frame(&mut self, _frame: AudioFrame, _timestamp: Duration) -> anyhow::Result<()> {+ Ok(())+ }+}diff --git a/crates/recording/src/test_sources/audio.rs b/crates/recording/src/test_sources/audio.rsnew file mode 100644index 000000000..e3dd6ce02--- /dev/null+++ b/crates/recording/src/test_sources/audio.rs@@ -0,0 +1,398 @@+use crate::output_pipeline::{AudioFrame, AudioSource, SetupCtx};+use cap_media_info::{AudioInfo, Sample, Type};+use cap_timestamp::{Timestamp, Timestamps};+use futures::channel::mpsc;+use std::{+ f32::consts::PI,+ sync::{+ Arc,+ atomic::{AtomicBool, Ordering},+ },+ time::Duration,+};+use tokio_util::sync::CancellationToken;++use super::{AudioGenerator, AudioTestConfig};++pub struct SyntheticAudioSource {+ info: AudioInfo,+ stop_flag: Arc<AtomicBool>,+}++pub struct SyntheticAudioSourceConfig {+ pub audio_config: AudioTestConfig,+ pub duration: Duration,+ pub timestamps: Timestamps,+ pub cancel_token: CancellationToken,+}++impl AudioSource for SyntheticAudioSource {+ type Config = SyntheticAudioSourceConfig;++ fn setup(+ config: Self::Config,+ tx: mpsc::Sender<AudioFrame>,+ ctx: &mut SetupCtx,+ ) -> impl std::future::Future<Output = anyhow::Result<Self>> + Send + 'static {+ let audio_config = config.audio_config;+ let info = AudioInfo::new_raw(+ audio_config.sample_format,+ audio_config.sample_rate,+ audio_config.channels,+ );++ let stop_flag = Arc::new(AtomicBool::new(false));+ let cancel_token = config.cancel_token;++ let buffer_size = 1024usize;+ let sample_duration =+ Duration::from_secs_f64(buffer_size as f64 / f64::from(audio_config.sample_rate));+ let total_samples =+ (config.duration.as_secs_f64() * f64::from(audio_config.sample_rate)) as u64;++ ctx.tasks().spawn("synthetic-audio-generator", {+ let stop_flag = stop_flag.clone();+ let cancel_token = cancel_token.clone();+ let timestamps = config.timestamps;+ let generator = audio_config.generator;+ let sample_rate = audio_config.sample_rate;+ let channels = audio_config.channels as usize;+ let sample_format = audio_config.sample_format;+ let mut tx = tx;++ async move {+ let mut sample_offset = 0u64;+ let start_instant = timestamps.instant();++ loop {+ if stop_flag.load(Ordering::Relaxed) || cancel_token.is_cancelled() {+ break;+ }++ if sample_offset >= total_samples {+ break;+ }++ let samples_to_generate =+ buffer_size.min((total_samples - sample_offset) as usize);++ let audio_data = generate_audio_samples(+ &generator,+ sample_rate,+ channels,+ sample_offset,+ samples_to_generate,+ );++ let frame = create_audio_frame(+ &audio_data,+ sample_format,+ sample_rate,+ channels,+ samples_to_generate,+ );++ let elapsed =+ Duration::from_secs_f64(sample_offset as f64 / f64::from(sample_rate));+ let timestamp = Timestamp::Instant(start_instant + elapsed);++ let audio_frame = AudioFrame::new(frame, timestamp);++ if tx.try_send(audio_frame).is_err() {+ if stop_flag.load(Ordering::Relaxed) || cancel_token.is_cancelled() {+ break;+ }+ tracing::warn!(+ "Audio frame channel full, samples {} dropped",+ sample_offset+ );+ }++ sample_offset += samples_to_generate as u64;++ let target_time = start_instant+ + sample_duration * (sample_offset / buffer_size as u64) as u32;+ let now = std::time::Instant::now();+ if target_time > now {+ tokio::time::sleep(target_time - now).await;+ }+ }++ tracing::info!(+ "Synthetic audio generator finished after {} samples",+ sample_offset+ );+ Ok(())+ }+ });++ async move { Ok(SyntheticAudioSource { info, stop_flag }) }+ }++ fn audio_info(&self) -> AudioInfo {+ self.info+ }++ fn stop(&mut self) -> impl std::future::Future<Output = anyhow::Result<()>> + Send {+ self.stop_flag.store(true, Ordering::Relaxed);+ async { Ok(()) }+ }+}++fn generate_audio_samples(+ generator: &AudioGenerator,+ sample_rate: u32,+ channels: usize,+ sample_offset: u64,+ sample_count: usize,+) -> Vec<f32> {+ let mut samples = Vec::with_capacity(sample_count * channels);++ match generator {+ AudioGenerator::SineWave { frequency } => {+ let angular_freq = 2.0 * PI * frequency / sample_rate as f32;++ for i in 0..sample_count {+ let t = (sample_offset + i as u64) as f32;+ let value = (angular_freq * t).sin() * 0.5;++ for _ in 0..channels {+ samples.push(value);+ }+ }+ }+ AudioGenerator::Chirp {+ start_freq,+ end_freq,+ } => {+ let total_duration = 5.0;+ let freq_range = end_freq - start_freq;++ for i in 0..sample_count {+ let t = (sample_offset + i as u64) as f32 / sample_rate as f32;+ let current_freq = start_freq + (freq_range * (t / total_duration).min(1.0));+ let angular_freq = 2.0 * PI * current_freq;+ let value = (angular_freq * t).sin() * 0.5;++ for _ in 0..channels {+ samples.push(value);+ }+ }+ }+ AudioGenerator::WhiteNoise => {+ use std::collections::hash_map::DefaultHasher;+ use std::hash::{Hash, Hasher};++ for i in 0..sample_count {+ let mut hasher = DefaultHasher::new();+ (sample_offset + i as u64).hash(&mut hasher);+ let hash = hasher.finish();++ let value = ((hash as f32 / u64::MAX as f32) * 2.0 - 1.0) * 0.3;++ for _ in 0..channels {+ samples.push(value);+ }+ }+ }+ AudioGenerator::Silence => {+ samples.resize(sample_count * channels, 0.0);+ }+ AudioGenerator::TimestampBeeps { beep_interval_ms } => {+ let beep_interval_samples =+ (sample_rate as f32 * *beep_interval_ms as f32 / 1000.0) as u64;+ let beep_duration_samples = (sample_rate as f32 * 0.05) as u64;+ let beep_freq = 1000.0;+ let angular_freq = 2.0 * PI * beep_freq / sample_rate as f32;++ for i in 0..sample_count {+ let global_sample = sample_offset + i as u64;+ let position_in_interval = global_sample % beep_interval_samples;++ let value = if position_in_interval < beep_duration_samples {+ (angular_freq * global_sample as f32).sin() * 0.7+ } else {+ 0.0+ };++ for _ in 0..channels {+ samples.push(value);+ }+ }+ }+ AudioGenerator::Square { frequency } => {+ let period_samples = sample_rate as f32 / frequency;++ for i in 0..sample_count {+ let t = (sample_offset + i as u64) as f32;+ let position_in_period = t % period_samples;+ let value = if position_in_period < period_samples / 2.0 {+ 0.5+ } else {+ -0.5+ };++ for _ in 0..channels {+ samples.push(value);+ }+ }+ }+ }++ samples+}++fn create_audio_frame(+ samples: &[f32],+ sample_format: Sample,+ sample_rate: u32,+ channels: usize,+ sample_count: usize,+) -> ffmpeg::frame::Audio {+ let channel_layout = match channels {+ 1 => ffmpeg::util::channel_layout::ChannelLayout::MONO,+ 2 => ffmpeg::util::channel_layout::ChannelLayout::STEREO,+ 6 => ffmpeg::util::channel_layout::ChannelLayout::_5POINT1,+ _ => ffmpeg::util::channel_layout::ChannelLayout::default(channels as i32),+ };++ let mut frame = ffmpeg::frame::Audio::new(sample_format, sample_count, channel_layout);+ frame.set_rate(sample_rate);++ match sample_format {+ Sample::F32(Type::Planar) => {+ for ch in 0..channels {+ let plane_data = frame.data_mut(ch);+ let plane_samples: &mut [f32] = unsafe {+ std::slice::from_raw_parts_mut(+ plane_data.as_mut_ptr() as *mut f32,+ sample_count,+ )+ };++ for (i, sample) in plane_samples.iter_mut().enumerate() {+ *sample = samples[i * channels + ch];+ }+ }+ }+ Sample::F32(Type::Packed) => {+ let plane_data = frame.data_mut(0);+ let plane_samples: &mut [f32] = unsafe {+ std::slice::from_raw_parts_mut(+ plane_data.as_mut_ptr() as *mut f32,+ sample_count * channels,+ )+ };+ plane_samples.copy_from_slice(samples);+ }+ Sample::I16(Type::Planar) => {+ for ch in 0..channels {+ let plane_data = frame.data_mut(ch);+ let plane_samples: &mut [i16] = unsafe {+ std::slice::from_raw_parts_mut(+ plane_data.as_mut_ptr() as *mut i16,+ sample_count,+ )+ };++ for (i, sample) in plane_samples.iter_mut().enumerate() {+ let f = samples[i * channels + ch];+ *sample = (f * 32767.0).clamp(-32768.0, 32767.0) as i16;+ }+ }+ }+ Sample::I16(Type::Packed) => {+ let plane_data = frame.data_mut(0);+ let plane_samples: &mut [i16] = unsafe {+ std::slice::from_raw_parts_mut(+ plane_data.as_mut_ptr() as *mut i16,+ sample_count * channels,+ )+ };++ for (i, sample) in plane_samples.iter_mut().enumerate() {+ let f = samples[i];+ *sample = (f * 32767.0).clamp(-32768.0, 32767.0) as i16;+ }+ }+ _ => {+ let plane_data = frame.data_mut(0);+ let plane_samples: &mut [f32] = unsafe {+ std::slice::from_raw_parts_mut(+ plane_data.as_mut_ptr() as *mut f32,+ sample_count.min(plane_data.len() / 4),+ )+ };+ let copy_len = plane_samples.len().min(samples.len());+ plane_samples[..copy_len].copy_from_slice(&samples[..copy_len]);+ }+ }++ frame+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn test_sine_wave_generation() {+ let samples = generate_audio_samples(+ &AudioGenerator::SineWave { frequency: 440.0 },+ 48000,+ 2,+ 0,+ 1024,+ );++ assert_eq!(samples.len(), 1024 * 2);++ for &sample in &samples {+ assert!(sample >= -1.0 && sample <= 1.0);+ }+ }++ #[test]+ fn test_silence_generation() {+ let samples = generate_audio_samples(&AudioGenerator::Silence, 48000, 2, 0, 1024);++ assert_eq!(samples.len(), 1024 * 2);++ for &sample in &samples {+ assert_eq!(sample, 0.0);+ }+ }++ #[test]+ fn test_timestamp_beeps() {+ let samples = generate_audio_samples(+ &AudioGenerator::TimestampBeeps {+ beep_interval_ms: 1000,+ },+ 48000,+ 1,+ 0,+ 48000,+ );++ assert_eq!(samples.len(), 48000);++ let first_beep_samples = &samples[0..2400];+ let has_audio = first_beep_samples.iter().any(|&s| s.abs() > 0.1);+ assert!(has_audio, "Should have audio in first beep period");++ let silence_samples = &samples[4800..48000];+ let mostly_silent =+ silence_samples.iter().filter(|&&s| s.abs() > 0.1).count() < silence_samples.len() / 10;+ assert!(mostly_silent, "Should be mostly silent after beep");+ }++ #[test]+ fn test_audio_info_creation() {+ let config = AudioTestConfig::broadcast_stereo();+ let info = AudioInfo::new_raw(config.sample_format, config.sample_rate, config.channels);++ assert_eq!(info.sample_rate, 48000);+ assert_eq!(info.channels, 2);+ }+}diff --git a/crates/recording/src/test_sources/config.rs b/crates/recording/src/test_sources/config.rsnew file mode 100644index 000000000..a96894b76--- /dev/null+++ b/crates/recording/src/test_sources/config.rs@@ -0,0 +1,350 @@+use cap_media_info::{Pixel, Sample, Type};+use std::time::Duration;++#[derive(Debug, Clone)]+pub struct TestConfig {+ pub video: Option<VideoTestConfig>,+ pub audio: Option<AudioTestConfig>,+ pub duration: Duration,+ pub output_format: OutputFormat,+}++impl Default for TestConfig {+ fn default() -> Self {+ Self {+ video: Some(VideoTestConfig::default()),+ audio: Some(AudioTestConfig::default()),+ duration: Duration::from_secs(5),+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ }+ }+}++#[derive(Debug, Clone)]+pub struct VideoTestConfig {+ pub width: u32,+ pub height: u32,+ pub frame_rate: u32,+ pub pixel_format: Pixel,+ pub pattern: TestPattern,+}++impl Default for VideoTestConfig {+ fn default() -> Self {+ Self {+ width: 1920,+ height: 1080,+ frame_rate: 30,+ pixel_format: Pixel::NV12,+ pattern: TestPattern::FrameCounter,+ }+ }+}++impl VideoTestConfig {+ pub fn with_resolution(mut self, width: u32, height: u32) -> Self {+ self.width = width;+ self.height = height;+ self+ }++ pub fn with_frame_rate(mut self, fps: u32) -> Self {+ self.frame_rate = fps;+ self+ }++ pub fn with_pixel_format(mut self, format: Pixel) -> Self {+ self.pixel_format = format;+ self+ }++ pub fn with_pattern(mut self, pattern: TestPattern) -> Self {+ self.pattern = pattern;+ self+ }++ pub fn hd_720p() -> Self {+ Self::default().with_resolution(1280, 720)+ }++ pub fn fhd_1080p() -> Self {+ Self::default().with_resolution(1920, 1080)+ }++ pub fn qhd_1440p() -> Self {+ Self::default().with_resolution(2560, 1440)+ }++ pub fn uhd_4k() -> Self {+ Self::default().with_resolution(3840, 2160)+ }++ pub fn ultrawide_1080() -> Self {+ Self::default().with_resolution(2560, 1080)+ }++ pub fn ultrawide_1440() -> Self {+ Self::default().with_resolution(3440, 1440)+ }++ pub fn super_ultrawide() -> Self {+ Self::default().with_resolution(5120, 1440)+ }++ pub fn portrait_1080() -> Self {+ Self::default().with_resolution(1080, 1920)+ }++ pub fn macbook_retina() -> Self {+ Self::default().with_resolution(2880, 1800)+ }++ pub fn macbook_pro_14() -> Self {+ Self::default().with_resolution(3024, 1964)+ }++ pub fn macbook_pro_16_promotion() -> Self {+ Self::default()+ .with_resolution(3456, 2234)+ .with_frame_rate(120)+ }++ pub fn webcam_vga() -> Self {+ Self::default().with_resolution(640, 480)+ }++ pub fn webcam_hd() -> Self {+ Self::default().with_resolution(1280, 720)+ }++ pub fn webcam_fhd() -> Self {+ Self::default().with_resolution(1920, 1080)+ }++ pub fn webcam_4k() -> Self {+ Self::default().with_resolution(3840, 2160)+ }+}++#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub enum TestPattern {+ SmpteColorBars,+ ColorGradient,+ FrameCounter,+ TimestampOverlay,+ Checkerboard,+ SolidColor { r: u8, g: u8, b: u8 },+ Random,+}++impl Default for TestPattern {+ fn default() -> Self {+ Self::FrameCounter+ }+}++#[derive(Debug, Clone)]+pub struct AudioTestConfig {+ pub sample_rate: u32,+ pub channels: u16,+ pub sample_format: Sample,+ pub generator: AudioGenerator,+}++impl Default for AudioTestConfig {+ fn default() -> Self {+ Self {+ sample_rate: 48000,+ channels: 2,+ sample_format: Sample::F32(Type::Planar),+ generator: AudioGenerator::SineWave { frequency: 440.0 },+ }+ }+}++impl AudioTestConfig {+ pub fn with_sample_rate(mut self, rate: u32) -> Self {+ self.sample_rate = rate;+ self+ }++ pub fn with_channels(mut self, channels: u16) -> Self {+ self.channels = channels;+ self+ }++ pub fn with_sample_format(mut self, format: Sample) -> Self {+ self.sample_format = format;+ self+ }++ pub fn with_generator(mut self, generator: AudioGenerator) -> Self {+ self.generator = generator;+ self+ }++ pub fn cd_quality_mono() -> Self {+ Self::default().with_sample_rate(44100).with_channels(1)+ }++ pub fn cd_quality_stereo() -> Self {+ Self::default().with_sample_rate(44100).with_channels(2)+ }++ pub fn broadcast_mono() -> Self {+ Self::default().with_sample_rate(48000).with_channels(1)+ }++ pub fn broadcast_stereo() -> Self {+ Self::default().with_sample_rate(48000).with_channels(2)+ }++ pub fn high_res_stereo() -> Self {+ Self::default().with_sample_rate(96000).with_channels(2)+ }++ pub fn surround_5_1() -> Self {+ Self::default().with_sample_rate(48000).with_channels(6)+ }++ pub fn voice_optimized() -> Self {+ Self::default()+ .with_sample_rate(16000)+ .with_channels(1)+ .with_sample_format(Sample::I16(Type::Planar))+ }+}++#[derive(Debug, Clone)]+pub enum AudioGenerator {+ SineWave { frequency: f32 },+ Chirp { start_freq: f32, end_freq: f32 },+ WhiteNoise,+ Silence,+ TimestampBeeps { beep_interval_ms: u32 },+ Square { frequency: f32 },+}++impl Default for AudioGenerator {+ fn default() -> Self {+ Self::SineWave { frequency: 440.0 }+ }+}++#[derive(Debug, Clone)]+pub enum OutputFormat {+ Mp4,+ FragmentedM4s { segment_duration: Duration },+ OggOpus,+}++impl Default for OutputFormat {+ fn default() -> Self {+ Self::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ }+ }+}++pub fn common_test_configs() -> Vec<TestConfig> {+ vec![+ TestConfig {+ video: Some(VideoTestConfig::fhd_1080p().with_frame_rate(30)),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration: Duration::from_secs(5),+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ TestConfig {+ video: Some(VideoTestConfig::fhd_1080p().with_frame_rate(60)),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration: Duration::from_secs(5),+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ TestConfig {+ video: Some(VideoTestConfig::hd_720p().with_frame_rate(30)),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration: Duration::from_secs(5),+ output_format: OutputFormat::Mp4,+ },+ TestConfig {+ video: Some(VideoTestConfig::uhd_4k().with_frame_rate(30)),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration: Duration::from_secs(5),+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ },+ ]+}++pub fn comprehensive_test_configs() -> Vec<TestConfig> {+ let mut configs = vec![];++ let resolutions = [+ (1280, 720),+ (1920, 1080),+ (2560, 1440),+ (3840, 2160),+ (2560, 1080),+ (3440, 1440),+ (1080, 1920),+ (2880, 1800),+ (3024, 1964),+ ];++ let frame_rates = [24, 30, 60];+ let pixel_formats = [Pixel::NV12, Pixel::BGRA];++ for (width, height) in resolutions {+ for fps in frame_rates {+ if width * height > 1920 * 1080 && fps > 60 {+ continue;+ }++ for pixel_format in pixel_formats {+ configs.push(TestConfig {+ video: Some(VideoTestConfig {+ width,+ height,+ frame_rate: fps,+ pixel_format,+ pattern: TestPattern::FrameCounter,+ }),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration: Duration::from_secs(5),+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ });+ }+ }+ }++ let audio_configs = [+ AudioTestConfig::cd_quality_mono(),+ AudioTestConfig::cd_quality_stereo(),+ AudioTestConfig::broadcast_mono(),+ AudioTestConfig::broadcast_stereo(),+ AudioTestConfig::high_res_stereo(),+ AudioTestConfig::voice_optimized(),+ ];++ for audio in audio_configs {+ configs.push(TestConfig {+ video: Some(VideoTestConfig::fhd_1080p()),+ audio: Some(audio),+ duration: Duration::from_secs(5),+ output_format: OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ });+ }++ configs+}diff --git a/crates/recording/src/test_sources/mod.rs b/crates/recording/src/test_sources/mod.rsnew file mode 100644index 000000000..a6e33022b--- /dev/null+++ b/crates/recording/src/test_sources/mod.rs@@ -0,0 +1,11 @@+mod audio;+mod config;+mod sync;+mod validation;+mod video;++pub use audio::*;+pub use config::*;+pub use sync::*;+pub use validation::*;+pub use video::*;diff --git a/crates/recording/src/test_sources/sync.rs b/crates/recording/src/test_sources/sync.rsnew file mode 100644index 000000000..e5b4d504c--- /dev/null+++ b/crates/recording/src/test_sources/sync.rs@@ -0,0 +1,366 @@+use std::time::Duration;++#[derive(Debug, Clone)]+pub struct SyncEvent {+ pub frame_number: u64,+ pub audio_sample: u64,+ pub expected_time_ms: f64,+}++#[derive(Debug, Clone)]+pub struct SyncTestConfig {+ pub video_fps: u32,+ pub audio_sample_rate: u32,+ pub sync_interval_ms: u32,+ pub duration: Duration,+}++impl Default for SyncTestConfig {+ fn default() -> Self {+ Self {+ video_fps: 30,+ audio_sample_rate: 48000,+ sync_interval_ms: 1000,+ duration: Duration::from_secs(5),+ }+ }+}++impl SyncTestConfig {+ pub fn generate_sync_events(&self) -> Vec<SyncEvent> {+ let mut events = vec![];++ let total_ms = self.duration.as_millis() as u32;+ let mut time_ms = 0u32;++ while time_ms < total_ms {+ let frame_number = (time_ms as f64 * self.video_fps as f64 / 1000.0) as u64;+ let audio_sample = (time_ms as f64 * self.audio_sample_rate as f64 / 1000.0) as u64;++ events.push(SyncEvent {+ frame_number,+ audio_sample,+ expected_time_ms: time_ms as f64,+ });++ time_ms += self.sync_interval_ms;+ }++ events+ }++ pub fn frames_per_sync_interval(&self) -> u32 {+ self.video_fps * self.sync_interval_ms / 1000+ }++ pub fn samples_per_sync_interval(&self) -> u32 {+ self.audio_sample_rate * self.sync_interval_ms / 1000+ }+}++#[derive(Debug, Clone, Default)]+pub struct SyncAnalysisResult {+ pub events: Vec<DetectedSyncEvent>,+ pub average_offset_ms: f64,+ pub max_offset_ms: f64,+ pub min_offset_ms: f64,+ pub std_deviation_ms: f64,+ pub sync_ok: bool,+}++#[derive(Debug, Clone)]+pub struct DetectedSyncEvent {+ pub expected_time_ms: f64,+ pub video_detected_ms: Option<f64>,+ pub audio_detected_ms: Option<f64>,+ pub offset_ms: f64,+}++impl SyncAnalysisResult {+ pub fn new(events: Vec<DetectedSyncEvent>, tolerance_ms: f64) -> Self {+ if events.is_empty() {+ return Self::default();+ }++ let offsets: Vec<f64> = events.iter().map(|e| e.offset_ms).collect();++ let sum: f64 = offsets.iter().sum();+ let count = offsets.len() as f64;+ let average_offset_ms = sum / count;++ let max_offset_ms = offsets+ .iter()+ .map(|o| o.abs())+ .fold(f64::NEG_INFINITY, f64::max);+ let min_offset_ms = offsets+ .iter()+ .map(|o| o.abs())+ .fold(f64::INFINITY, f64::min);++ let variance: f64 = offsets+ .iter()+ .map(|o| (o - average_offset_ms).powi(2))+ .sum::<f64>()+ / count;+ let std_deviation_ms = variance.sqrt();++ let sync_ok = max_offset_ms <= tolerance_ms;++ Self {+ events,+ average_offset_ms,+ max_offset_ms,+ min_offset_ms,+ std_deviation_ms,+ sync_ok,+ }+ }++ pub fn is_within_tolerance(&self, tolerance_ms: f64) -> bool {+ self.max_offset_ms <= tolerance_ms+ }+}++pub fn frame_number_to_time_ms(frame_number: u64, fps: u32) -> f64 {+ frame_number as f64 * 1000.0 / fps as f64+}++pub fn sample_number_to_time_ms(sample_number: u64, sample_rate: u32) -> f64 {+ sample_number as f64 * 1000.0 / sample_rate as f64+}++pub fn time_ms_to_frame_number(time_ms: f64, fps: u32) -> u64 {+ (time_ms * fps as f64 / 1000.0).round() as u64+}++pub fn time_ms_to_sample_number(time_ms: f64, sample_rate: u32) -> u64 {+ (time_ms * sample_rate as f64 / 1000.0).round() as u64+}++#[derive(Debug, Clone)]+pub struct SyncMarker {+ pub marker_type: SyncMarkerType,+ pub time_ms: f64,+ pub frame_number: Option<u64>,+ pub sample_number: Option<u64>,+}++#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub enum SyncMarkerType {+ VideoFlash,+ AudioBeep,+ Combined,+}++pub struct SyncDetector {+ _video_fps: u32,+ _audio_sample_rate: u32,+ flash_threshold: u8,+ beep_threshold: f32,+ beep_frequency: f32,+}++impl SyncDetector {+ pub fn new(video_fps: u32, audio_sample_rate: u32) -> Self {+ Self {+ _video_fps: video_fps,+ _audio_sample_rate: audio_sample_rate,+ flash_threshold: 200,+ beep_threshold: 0.3,+ beep_frequency: 1000.0,+ }+ }++ pub fn with_flash_threshold(mut self, threshold: u8) -> Self {+ self.flash_threshold = threshold;+ self+ }++ pub fn with_beep_threshold(mut self, threshold: f32) -> Self {+ self.beep_threshold = threshold;+ self+ }++ pub fn detect_flash_in_frame(&self, y_plane: &[u8], width: usize, height: usize) -> bool {+ if y_plane.is_empty() {+ return false;+ }++ let sample_region_width = (width / 4).max(1);+ let sample_region_height = (height / 4).max(1);+ let start_x = width / 2 - sample_region_width / 2;+ let start_y = height / 2 - sample_region_height / 2;++ let mut sum = 0u64;+ let mut count = 0u64;++ for y in start_y..(start_y + sample_region_height) {+ for x in start_x..(start_x + sample_region_width) {+ let idx = y * width + x;+ if idx < y_plane.len() {+ sum += y_plane[idx] as u64;+ count += 1;+ }+ }+ }++ if count == 0 {+ return false;+ }++ let average = (sum / count) as u8;+ average >= self.flash_threshold+ }++ pub fn detect_beep_in_audio(&self, samples: &[f32], sample_rate: u32) -> Option<usize> {+ if samples.is_empty() {+ return None;+ }++ let window_size = (sample_rate as f32 / self.beep_frequency * 2.0) as usize;+ let window_size = window_size.max(64).min(samples.len());++ for (start_idx, window) in samples.windows(window_size).enumerate() {+ let energy: f32 = window.iter().map(|s| s.abs()).sum::<f32>() / window.len() as f32;++ if energy >= self.beep_threshold {+ return Some(start_idx);+ }+ }++ None+ }++ pub fn analyze_sync(+ &self,+ video_markers: &[SyncMarker],+ audio_markers: &[SyncMarker],+ tolerance_ms: f64,+ ) -> SyncAnalysisResult {+ let mut events = vec![];++ for video_marker in video_markers {+ let closest_audio = audio_markers.iter().min_by(|a, b| {+ let diff_a = (a.time_ms - video_marker.time_ms).abs();+ let diff_b = (b.time_ms - video_marker.time_ms).abs();+ diff_a.partial_cmp(&diff_b).unwrap()+ });++ let (audio_time, offset) = if let Some(audio) = closest_audio {+ let offset = audio.time_ms - video_marker.time_ms;+ (Some(audio.time_ms), offset)+ } else {+ (None, 0.0)+ };++ events.push(DetectedSyncEvent {+ expected_time_ms: video_marker.time_ms,+ video_detected_ms: Some(video_marker.time_ms),+ audio_detected_ms: audio_time,+ offset_ms: offset,+ });+ }++ SyncAnalysisResult::new(events, tolerance_ms)+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn test_sync_event_generation() {+ let config = SyncTestConfig {+ video_fps: 30,+ audio_sample_rate: 48000,+ sync_interval_ms: 1000,+ duration: Duration::from_secs(5),+ };++ let events = config.generate_sync_events();++ assert_eq!(events.len(), 5);+ assert_eq!(events[0].expected_time_ms, 0.0);+ assert_eq!(events[1].expected_time_ms, 1000.0);+ assert_eq!(events[0].frame_number, 0);+ assert_eq!(events[1].frame_number, 30);+ assert_eq!(events[0].audio_sample, 0);+ assert_eq!(events[1].audio_sample, 48000);+ }++ #[test]+ fn test_time_conversions() {+ assert_eq!(frame_number_to_time_ms(30, 30), 1000.0);+ assert_eq!(frame_number_to_time_ms(60, 60), 1000.0);++ assert_eq!(sample_number_to_time_ms(48000, 48000), 1000.0);+ assert_eq!(sample_number_to_time_ms(44100, 44100), 1000.0);++ assert_eq!(time_ms_to_frame_number(1000.0, 30), 30);+ assert_eq!(time_ms_to_sample_number(1000.0, 48000), 48000);+ }++ #[test]+ fn test_sync_analysis() {+ let events = vec![+ DetectedSyncEvent {+ expected_time_ms: 0.0,+ video_detected_ms: Some(0.0),+ audio_detected_ms: Some(5.0),+ offset_ms: 5.0,+ },+ DetectedSyncEvent {+ expected_time_ms: 1000.0,+ video_detected_ms: Some(1000.0),+ audio_detected_ms: Some(1010.0),+ offset_ms: 10.0,+ },+ DetectedSyncEvent {+ expected_time_ms: 2000.0,+ video_detected_ms: Some(2000.0),+ audio_detected_ms: Some(2015.0),+ offset_ms: 15.0,+ },+ ];++ let result = SyncAnalysisResult::new(events, 50.0);++ assert_eq!(result.average_offset_ms, 10.0);+ assert_eq!(result.max_offset_ms, 15.0);+ assert_eq!(result.min_offset_ms, 5.0);+ assert!(result.sync_ok);+ assert!(result.is_within_tolerance(50.0));+ assert!(!result.is_within_tolerance(10.0));+ }++ #[test]+ fn test_flash_detection() {+ let detector = SyncDetector::new(30, 48000);++ let bright_frame: Vec<u8> = vec![255; 1920 * 1080];+ assert!(detector.detect_flash_in_frame(&bright_frame, 1920, 1080));++ let dark_frame: Vec<u8> = vec![16; 1920 * 1080];+ assert!(!detector.detect_flash_in_frame(&dark_frame, 1920, 1080));+ }++ #[test]+ fn test_beep_detection() {+ let detector = SyncDetector::new(30, 48000);++ let loud_samples: Vec<f32> = vec![0.5; 4800];+ assert!(+ detector+ .detect_beep_in_audio(&loud_samples, 48000)+ .is_some()+ );++ let silent_samples: Vec<f32> = vec![0.0; 4800];+ assert!(+ detector+ .detect_beep_in_audio(&silent_samples, 48000)+ .is_none()+ );+ }+}diff --git a/crates/recording/src/test_sources/validation.rs b/crates/recording/src/test_sources/validation.rsnew file mode 100644index 000000000..805608114--- /dev/null+++ b/crates/recording/src/test_sources/validation.rs@@ -0,0 +1,628 @@+use anyhow::Context;+use cap_media_info::{AudioInfo, VideoInfo};+use std::{+ path::{Path, PathBuf},+ time::Duration,+};++use super::TestConfig;++#[derive(Debug, Clone)]+pub struct ValidationResult {+ pub frame_count_ok: bool,+ pub expected_frames: u64,+ pub actual_frames: u64,+ pub duration_ok: bool,+ pub expected_duration: Duration,+ pub actual_duration: Duration,+ pub av_sync_offset_ms: f64,+ pub av_sync_ok: bool,+ pub dropped_frames: u64,+ pub fragment_integrity: bool,+ pub fragments_checked: usize,+ pub fragments_valid: usize,+ pub errors: Vec<String>,+}++impl ValidationResult {+ pub fn is_valid(&self) -> bool {+ self.frame_count_ok+ && self.duration_ok+ && self.av_sync_ok+ && self.fragment_integrity+ && self.errors.is_empty()+ }++ pub fn summary(&self) -> String {+ let mut lines = vec![];++ lines.push(format!(+ "Frame count: {}/{} ({})",+ self.actual_frames,+ self.expected_frames,+ if self.frame_count_ok { "OK" } else { "FAIL" }+ ));++ lines.push(format!(+ "Duration: {:.2}s/{:.2}s ({})",+ self.actual_duration.as_secs_f64(),+ self.expected_duration.as_secs_f64(),+ if self.duration_ok { "OK" } else { "FAIL" }+ ));++ lines.push(format!(+ "A/V sync: {:.1}ms offset ({})",+ self.av_sync_offset_ms,+ if self.av_sync_ok { "OK" } else { "FAIL" }+ ));++ if self.dropped_frames > 0 {+ lines.push(format!("Dropped frames: {}", self.dropped_frames));+ }++ lines.push(format!(+ "Fragments: {}/{} valid ({})",+ self.fragments_valid,+ self.fragments_checked,+ if self.fragment_integrity {+ "OK"+ } else {+ "FAIL"+ }+ ));++ if !self.errors.is_empty() {+ lines.push(format!("Errors: {}", self.errors.join(", ")));+ }++ lines.join("\n")+ }+}++impl Default for ValidationResult {+ fn default() -> Self {+ Self {+ frame_count_ok: false,+ expected_frames: 0,+ actual_frames: 0,+ duration_ok: false,+ expected_duration: Duration::ZERO,+ actual_duration: Duration::ZERO,+ av_sync_offset_ms: 0.0,+ av_sync_ok: true,+ dropped_frames: 0,+ fragment_integrity: true,+ fragments_checked: 0,+ fragments_valid: 0,+ errors: vec![],+ }+ }+}++#[derive(Debug, Clone)]+pub struct ValidationConfig {+ pub frame_count_tolerance: f64,+ pub duration_tolerance: Duration,+ pub av_sync_tolerance_ms: f64,+ pub check_fragments: bool,+}++impl Default for ValidationConfig {+ fn default() -> Self {+ Self {+ frame_count_tolerance: 0.02,+ duration_tolerance: Duration::from_millis(500),+ av_sync_tolerance_ms: 50.0,+ check_fragments: true,+ }+ }+}++pub struct RecordingValidator {+ config: ValidationConfig,+ expected_video_info: Option<VideoInfo>,+ expected_audio_info: Option<AudioInfo>,+ expected_duration: Duration,+}++impl RecordingValidator {+ pub fn new(test_config: &TestConfig) -> Self {+ let expected_video_info = test_config.video.as_ref().map(|v| VideoInfo {+ pixel_format: v.pixel_format,+ width: v.width,+ height: v.height,+ time_base: ffmpeg::util::rational::Rational(1, 1_000_000),+ frame_rate: ffmpeg::util::rational::Rational(v.frame_rate as i32, 1),+ });++ let expected_audio_info = test_config+ .audio+ .as_ref()+ .map(|a| AudioInfo::new_raw(a.sample_format, a.sample_rate, a.channels));++ Self {+ config: ValidationConfig::default(),+ expected_video_info,+ expected_audio_info,+ expected_duration: test_config.duration,+ }+ }++ pub fn with_config(mut self, config: ValidationConfig) -> Self {+ self.config = config;+ self+ }++ pub fn expected_frame_count(&self) -> u64 {+ if let Some(video) = &self.expected_video_info {+ (self.expected_duration.as_secs_f64() * video.frame_rate.0 as f64) as u64+ } else {+ 0+ }+ }++ pub async fn validate_mp4(&self, path: &Path) -> anyhow::Result<ValidationResult> {+ let mut result = ValidationResult {+ expected_frames: self.expected_frame_count(),+ expected_duration: self.expected_duration,+ ..Default::default()+ };++ let probe = probe_media_file(path).await?;++ if let Some(video_info) = &probe.video_info {+ result.actual_frames = probe.video_frame_count;+ result.actual_duration = probe.duration;++ let tolerance_frames =+ (result.expected_frames as f64 * self.config.frame_count_tolerance) as u64;+ let frame_diff = if result.actual_frames > result.expected_frames {+ result.actual_frames - result.expected_frames+ } else {+ result.expected_frames - result.actual_frames+ };+ result.frame_count_ok = frame_diff <= tolerance_frames.max(2);++ if result.actual_frames < result.expected_frames {+ result.dropped_frames = result.expected_frames - result.actual_frames;+ }++ let duration_diff = if result.actual_duration > self.expected_duration {+ result.actual_duration - self.expected_duration+ } else {+ self.expected_duration - result.actual_duration+ };+ result.duration_ok = duration_diff <= self.config.duration_tolerance;++ if let Some(expected) = &self.expected_video_info {+ if video_info.width != expected.width || video_info.height != expected.height {+ result.errors.push(format!(+ "Resolution mismatch: expected {}x{}, got {}x{}",+ expected.width, expected.height, video_info.width, video_info.height+ ));+ }+ }+ } else if self.expected_video_info.is_some() {+ result.errors.push("No video stream found".to_string());+ } else {+ result.frame_count_ok = true;+ result.actual_duration = probe.duration;++ let duration_diff = if result.actual_duration > self.expected_duration {+ result.actual_duration - self.expected_duration+ } else {+ self.expected_duration - result.actual_duration+ };+ result.duration_ok = duration_diff <= self.config.duration_tolerance;+ }++ if self.expected_audio_info.is_some() && probe.audio_info.is_none() {+ result.errors.push("No audio stream found".to_string());+ }++ result.av_sync_ok = true;+ result.fragment_integrity = true;++ Ok(result)+ }++ pub async fn validate_m4s_fragments(&self, dir: &Path) -> anyhow::Result<ValidationResult> {+ let mut result = ValidationResult {+ expected_frames: self.expected_frame_count(),+ expected_duration: self.expected_duration,+ ..Default::default()+ };++ let init_segment = dir.join("init.mp4");+ if !init_segment.exists() {+ result.errors.push("Missing init.mp4 segment".to_string());+ result.fragment_integrity = false;+ return Ok(result);+ }++ let mut fragments = vec![];+ let entries = std::fs::read_dir(dir).context("Failed to read fragment directory")?;++ for entry in entries {+ let entry = entry?;+ let path = entry.path();+ if let Some(ext) = path.extension() {+ if ext == "m4s" {+ fragments.push(path);+ }+ }+ }++ fragments.sort();++ result.fragments_checked = fragments.len();++ for fragment in &fragments {+ if let Ok(metadata) = std::fs::metadata(fragment) {+ if metadata.len() > 0 {+ result.fragments_valid += 1;+ }+ }+ }++ result.fragment_integrity = result.fragments_valid == result.fragments_checked;++ if !fragments.is_empty() {+ let combined_path = dir.join("combined_for_validation.mp4");+ if let Ok(probe_result) =+ create_combined_mp4_and_probe(&init_segment, &fragments, &combined_path).await+ {+ result.actual_frames = probe_result.frame_count;+ result.actual_duration = probe_result.duration;++ let tolerance_frames =+ (result.expected_frames as f64 * self.config.frame_count_tolerance) as u64;+ let frame_diff = result.actual_frames.abs_diff(result.expected_frames);+ result.frame_count_ok = frame_diff <= tolerance_frames.max(2);++ if result.actual_frames < result.expected_frames {+ result.dropped_frames = result.expected_frames - result.actual_frames;+ }++ let duration_diff = if result.actual_duration > self.expected_duration {+ result.actual_duration - self.expected_duration+ } else {+ self.expected_duration - result.actual_duration+ };+ result.duration_ok = duration_diff <= self.config.duration_tolerance;++ let _ = std::fs::remove_file(&combined_path);+ } else {+ result.frame_count_ok = true;+ result.duration_ok = true;+ }+ result.av_sync_ok = true;+ }++ Ok(result)+ }++ pub fn verify_frame_sequence(&self, frame_numbers: &[u64]) -> FrameSequenceResult {+ let mut result = FrameSequenceResult {+ total_frames: frame_numbers.len(),+ ..Default::default()+ };++ if frame_numbers.is_empty() {+ return result;+ }++ let mut expected = frame_numbers[0];+ for &actual in frame_numbers.iter().skip(1) {+ expected += 1;+ if actual != expected {+ if actual > expected {+ result.gaps.push((expected, actual - 1));+ result.dropped_count += (actual - expected) as usize;+ } else {+ result.duplicates.push(actual);+ result.duplicate_count += 1;+ }+ expected = actual;+ }+ }++ result.is_sequential = result.gaps.is_empty() && result.duplicates.is_empty();++ result+ }+}++#[derive(Debug, Clone, Default)]+pub struct FrameSequenceResult {+ pub total_frames: usize,+ pub is_sequential: bool,+ pub gaps: Vec<(u64, u64)>,+ pub duplicates: Vec<u64>,+ pub dropped_count: usize,+ pub duplicate_count: usize,+}++#[derive(Debug, Clone, Default)]+struct MediaProbeResult {+ video_info: Option<VideoInfo>,+ audio_info: Option<AudioInfo>,+ duration: Duration,+ video_frame_count: u64,+ #[allow(dead_code)]+ audio_sample_count: u64,+}++async fn probe_media_file(path: &Path) -> anyhow::Result<MediaProbeResult> {+ let mut result = MediaProbeResult::default();++ let mut input = ffmpeg::format::input(path).context("Failed to open media file")?;++ if let Some(duration) = input+ .duration()+ .checked_div(ffmpeg::ffi::AV_TIME_BASE as i64)+ {+ result.duration = Duration::from_secs(duration.max(0) as u64);+ }++ let mut video_stream_index: Option<usize> = None;+ let mut video_time_base = ffmpeg::util::rational::Rational(1, 1);++ for stream in input.streams() {+ let codec = stream.parameters();++ match codec.medium() {+ ffmpeg::media::Type::Video => {+ if let Ok(decoder) = ffmpeg::codec::context::Context::from_parameters(codec) {+ if let Ok(video) = decoder.decoder().video() {+ result.video_info = Some(VideoInfo {+ pixel_format: video.format(),+ width: video.width(),+ height: video.height(),+ time_base: stream.time_base(),+ frame_rate: stream.avg_frame_rate(),+ });++ result.video_frame_count = stream.frames() as u64;+ video_stream_index = Some(stream.index());+ video_time_base = stream.time_base();+ }+ }+ }+ ffmpeg::media::Type::Audio => {+ if let Ok(decoder) = ffmpeg::codec::context::Context::from_parameters(codec) {+ if let Ok(audio) = decoder.decoder().audio() {+ if let Ok(info) = AudioInfo::from_decoder(&audio) {+ result.audio_info = Some(info);+ }+ }+ }+ }+ _ => {}+ }+ }++ if result.video_frame_count == 0 {+ if let Some(video_idx) = video_stream_index {+ let mut last_pts: Option<i64> = None;+ for (stream, packet) in input.packets() {+ if stream.index() == video_idx {+ result.video_frame_count += 1;+ if let Some(pts) = packet.pts() {+ last_pts = Some(pts);+ }+ }+ }++ if let Some(pts) = last_pts {+ let duration_secs =+ pts as f64 * video_time_base.0 as f64 / video_time_base.1 as f64;+ result.duration = Duration::from_secs_f64(duration_secs.max(0.0));+ }+ }+ }++ Ok(result)+}++struct SegmentProbeResult {+ frame_count: u64,+ duration: Duration,+}++async fn create_combined_mp4_and_probe(+ init_segment: &Path,+ fragments: &[PathBuf],+ output_path: &Path,+) -> anyhow::Result<SegmentProbeResult> {+ let mut combined_data = std::fs::read(init_segment)?;++ for fragment in fragments {+ let fragment_data = std::fs::read(fragment)?;+ combined_data.extend(fragment_data);+ }++ std::fs::write(output_path, &combined_data)?;++ let mut input = ffmpeg::format::input(output_path).context("Failed to open combined MP4")?;++ let mut frame_count = 0u64;+ let mut duration = Duration::ZERO;+ let mut video_stream_index: Option<usize> = None;+ let mut time_base = ffmpeg::util::rational::Rational(1, 1);+ let mut last_pts: Option<i64> = None;++ for stream in input.streams() {+ let codec = stream.parameters();++ if codec.medium() == ffmpeg::media::Type::Video {+ video_stream_index = Some(stream.index());+ time_base = stream.time_base();++ frame_count = stream.frames() as u64;+ if frame_count > 0 {+ if let Some(dur) = input+ .duration()+ .checked_div(ffmpeg::ffi::AV_TIME_BASE as i64)+ {+ duration = Duration::from_secs(dur.max(0) as u64);+ }+ return Ok(SegmentProbeResult {+ frame_count,+ duration,+ });+ }+ break;+ }+ }++ if let Some(video_idx) = video_stream_index {+ for (stream, packet) in input.packets() {+ if stream.index() == video_idx {+ frame_count += 1;+ if let Some(pts) = packet.pts() {+ last_pts = Some(pts);+ }+ }+ }++ if let Some(pts) = last_pts {+ let duration_secs = pts as f64 * time_base.0 as f64 / time_base.1 as f64;+ duration = Duration::from_secs_f64(duration_secs.max(0.0));+ }+ }++ Ok(SegmentProbeResult {+ frame_count,+ duration,+ })+}++pub async fn run_test_recording(+ config: &TestConfig,+ output_dir: &Path,+) -> anyhow::Result<TestRecordingResult> {+ std::fs::create_dir_all(output_dir)?;++ let output_path = output_dir.join("test_recording");++ Ok(TestRecordingResult {+ output_path,+ config: config.clone(),+ })+}++#[derive(Debug)]+pub struct TestRecordingResult {+ pub output_path: PathBuf,+ pub config: TestConfig,+}++pub fn calculate_expected_file_size(config: &TestConfig) -> u64 {+ let mut size = 0u64;++ if let Some(video) = &config.video {+ let pixels_per_frame = video.width as u64 * video.height as u64;+ let bytes_per_pixel = 1.5;+ let raw_frame_size = (pixels_per_frame as f64 * bytes_per_pixel) as u64;++ let compression_ratio = 50.0;+ let frames = (config.duration.as_secs_f64() * video.frame_rate as f64) as u64;+ size += (raw_frame_size * frames) / compression_ratio as u64;+ }++ if let Some(audio) = &config.audio {+ let samples = (config.duration.as_secs_f64() * audio.sample_rate as f64) as u64;+ let bytes_per_sample = 2;+ let channels = audio.channels as u64;++ let compression_ratio = 10.0;+ size += (samples * bytes_per_sample * channels) / compression_ratio as u64;+ }++ size+}++#[cfg(test)]+mod tests {+ use super::*;+ use crate::test_sources::{AudioTestConfig, OutputFormat, VideoTestConfig};++ #[test]+ fn test_validation_result_summary() {+ let result = ValidationResult {+ frame_count_ok: true,+ expected_frames: 150,+ actual_frames: 148,+ duration_ok: true,+ expected_duration: Duration::from_secs(5),+ actual_duration: Duration::from_secs_f64(4.93),+ av_sync_offset_ms: 12.5,+ av_sync_ok: true,+ dropped_frames: 2,+ fragment_integrity: true,+ fragments_checked: 2,+ fragments_valid: 2,+ errors: vec![],+ };++ let summary = result.summary();+ assert!(summary.contains("148/150"));+ assert!(summary.contains("12.5ms"));+ assert!(summary.contains("Dropped frames: 2"));+ }++ #[test]+ fn test_frame_sequence_validation() {+ let config = TestConfig::default();+ let validator = RecordingValidator::new(&config);++ let sequential = vec![0, 1, 2, 3, 4, 5];+ let result = validator.verify_frame_sequence(&sequential);+ assert!(result.is_sequential);+ assert_eq!(result.dropped_count, 0);++ let with_gap = vec![0, 1, 2, 5, 6, 7];+ let result = validator.verify_frame_sequence(&with_gap);+ assert!(!result.is_sequential);+ assert_eq!(result.dropped_count, 2);+ assert_eq!(result.gaps, vec![(3, 4)]);++ let with_duplicate = vec![0, 1, 2, 2, 3, 4];+ let result = validator.verify_frame_sequence(&with_duplicate);+ assert!(!result.is_sequential);+ assert_eq!(result.duplicate_count, 1);+ }++ #[test]+ fn test_expected_frame_count() {+ let config = TestConfig {+ video: Some(VideoTestConfig {+ width: 1920,+ height: 1080,+ frame_rate: 30,+ ..Default::default()+ }),+ audio: None,+ duration: Duration::from_secs(5),+ output_format: OutputFormat::Mp4,+ };++ let validator = RecordingValidator::new(&config);+ assert_eq!(validator.expected_frame_count(), 150);+ }++ #[test]+ fn test_file_size_estimation() {+ let config = TestConfig {+ video: Some(VideoTestConfig::fhd_1080p()),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration: Duration::from_secs(5),+ output_format: OutputFormat::Mp4,+ };++ let size = calculate_expected_file_size(&config);+ assert!(size > 0);+ assert!(size < 100_000_000);+ }+}diff --git a/crates/recording/src/test_sources/video.rs b/crates/recording/src/test_sources/video.rsnew file mode 100644index 000000000..760059079--- /dev/null+++ b/crates/recording/src/test_sources/video.rs@@ -0,0 +1,637 @@+use crate::output_pipeline::{FFmpegVideoFrame, SetupCtx, VideoSource};+use cap_media_info::{Pixel, VideoInfo};+use cap_timestamp::{Timestamp, Timestamps};+use ffmpeg::util::rational::Rational as FFRational;+use futures::{FutureExt, channel::mpsc};+use std::{+ sync::{+ Arc,+ atomic::{AtomicBool, Ordering},+ },+ time::Duration,+};+use tokio_util::sync::CancellationToken;++use super::{TestPattern, VideoTestConfig};++pub struct TestPatternVideoSource {+ info: VideoInfo,+ stop_flag: Arc<AtomicBool>,+}++pub struct TestPatternVideoSourceConfig {+ pub video_config: VideoTestConfig,+ pub duration: Duration,+ pub timestamps: Timestamps,+ pub cancel_token: CancellationToken,+}++impl VideoSource for TestPatternVideoSource {+ type Config = TestPatternVideoSourceConfig;+ type Frame = FFmpegVideoFrame;++ async fn setup(+ config: Self::Config,+ video_tx: mpsc::Sender<Self::Frame>,+ ctx: &mut SetupCtx,+ ) -> anyhow::Result<Self> {+ let video_config = config.video_config;+ let info = VideoInfo {+ pixel_format: video_config.pixel_format,+ width: video_config.width,+ height: video_config.height,+ time_base: FFRational(1, 1_000_000),+ frame_rate: FFRational(video_config.frame_rate as i32, 1),+ };++ let pattern = video_config.pattern;+ let stop_flag = Arc::new(AtomicBool::new(false));+ let cancel_token = config.cancel_token;++ let frame_duration = Duration::from_secs_f64(1.0 / f64::from(video_config.frame_rate));+ let total_frames =+ (config.duration.as_secs_f64() * f64::from(video_config.frame_rate)) as u64;++ ctx.tasks().spawn("synthetic-video-generator", {+ let stop_flag = stop_flag.clone();+ let cancel_token = cancel_token.clone();+ let timestamps = config.timestamps;+ let mut video_tx = video_tx;++ async move {+ let mut frame_number = 0u64;+ let start_instant = timestamps.instant();++ loop {+ if stop_flag.load(Ordering::Relaxed) || cancel_token.is_cancelled() {+ break;+ }++ if frame_number >= total_frames {+ break;+ }++ let target_time = start_instant + frame_duration * frame_number as u32;+ let now = std::time::Instant::now();+ if target_time > now {+ tokio::time::sleep(target_time - now).await;+ }++ let frame = generate_video_frame(&info, pattern, frame_number);++ let timestamp =+ Timestamp::Instant(start_instant + frame_duration * frame_number as u32);++ let ffmpeg_frame = FFmpegVideoFrame {+ inner: frame,+ timestamp,+ };++ if video_tx.try_send(ffmpeg_frame).is_err() {+ if stop_flag.load(Ordering::Relaxed) || cancel_token.is_cancelled() {+ break;+ }+ tracing::warn!("Video frame channel full, frame {} dropped", frame_number);+ }++ frame_number += 1;+ }++ tracing::info!(+ "Synthetic video generator finished after {} frames",+ frame_number+ );+ Ok(())+ }+ });++ Ok(Self { info, stop_flag })+ }++ fn video_info(&self) -> VideoInfo {+ self.info+ }++ fn stop(&mut self) -> futures::future::BoxFuture<'_, anyhow::Result<()>> {+ self.stop_flag.store(true, Ordering::Relaxed);+ async { Ok(()) }.boxed()+ }+}++fn generate_video_frame(+ info: &VideoInfo,+ pattern: TestPattern,+ frame_number: u64,+) -> ffmpeg::frame::Video {+ let mut frame = ffmpeg::frame::Video::new(info.pixel_format, info.width, info.height);+ frame.set_pts(Some((frame_number * 33333) as i64));++ match pattern {+ TestPattern::SmpteColorBars => {+ fill_smpte_bars(&mut frame, info);+ }+ TestPattern::ColorGradient => {+ fill_color_gradient(&mut frame, info, frame_number);+ }+ TestPattern::FrameCounter => {+ fill_frame_counter(&mut frame, info, frame_number);+ }+ TestPattern::TimestampOverlay => {+ fill_timestamp_overlay(&mut frame, info, frame_number);+ }+ TestPattern::Checkerboard => {+ fill_checkerboard(&mut frame, info, frame_number);+ }+ TestPattern::SolidColor { r, g, b } => {+ fill_solid_color(&mut frame, info, r, g, b);+ }+ TestPattern::Random => {+ fill_random(&mut frame, info, frame_number);+ }+ }++ frame+}++fn fill_smpte_bars(frame: &mut ffmpeg::frame::Video, info: &VideoInfo) {+ let colors_rgb: [(u8, u8, u8); 8] = [+ (192, 192, 192),+ (192, 192, 0),+ (0, 192, 192),+ (0, 192, 0),+ (192, 0, 192),+ (192, 0, 0),+ (0, 0, 192),+ (0, 0, 0),+ ];++ let width = info.width as usize;+ let height = info.height as usize;+ let bar_width = width / 8;++ match info.pixel_format {+ Pixel::BGRA | Pixel::RGBA => {+ let stride = frame.stride(0);+ let is_bgra = info.pixel_format == Pixel::BGRA;+ let data = frame.data_mut(0);++ for y in 0..height {+ for x in 0..width {+ let bar_idx = (x / bar_width).min(7);+ let (r, g, b) = colors_rgb[bar_idx];+ let offset = y * stride + x * 4;++ if offset + 3 < data.len() {+ if is_bgra {+ data[offset] = b;+ data[offset + 1] = g;+ data[offset + 2] = r;+ data[offset + 3] = 255;+ } else {+ data[offset] = r;+ data[offset + 1] = g;+ data[offset + 2] = b;+ data[offset + 3] = 255;+ }+ }+ }+ }+ }+ Pixel::NV12 => {+ let y_stride = frame.stride(0);+ let uv_stride = frame.stride(1);++ {+ let y_data = frame.data_mut(0);+ for y in 0..height {+ for x in 0..width {+ let bar_idx = (x / bar_width).min(7);+ let (r, g, b) = colors_rgb[bar_idx];+ let y_val = rgb_to_y(r, g, b);++ let y_offset = y * y_stride + x;+ if y_offset < y_data.len() {+ y_data[y_offset] = y_val;+ }+ }+ }+ }++ {+ let uv_data = frame.data_mut(1);+ for y in (0..height).step_by(2) {+ for x in (0..width).step_by(2) {+ let bar_idx = (x / bar_width).min(7);+ let (r, g, b) = colors_rgb[bar_idx];+ let (u, v) = rgb_to_uv(r, g, b);++ let uv_offset = (y / 2) * uv_stride + x;+ if uv_offset + 1 < uv_data.len() {+ uv_data[uv_offset] = u;+ uv_data[uv_offset + 1] = v;+ }+ }+ }+ }+ }+ _ => {+ fill_random_fallback(frame, info, 0);+ }+ }+}++fn fill_color_gradient(frame: &mut ffmpeg::frame::Video, info: &VideoInfo, frame_number: u64) {+ let width = info.width as usize;+ let height = info.height as usize;+ let phase = (frame_number % 256) as u8;++ match info.pixel_format {+ Pixel::BGRA | Pixel::RGBA => {+ let stride = frame.stride(0);+ let is_bgra = info.pixel_format == Pixel::BGRA;+ let data = frame.data_mut(0);++ for y in 0..height {+ for x in 0..width {+ let r = ((x * 255 / width) as u8).wrapping_add(phase);+ let g = ((y * 255 / height) as u8).wrapping_add(phase);+ let b = (((x + y) * 255 / (width + height)) as u8).wrapping_add(phase);++ let offset = y * stride + x * 4;+ if offset + 3 < data.len() {+ if is_bgra {+ data[offset] = b;+ data[offset + 1] = g;+ data[offset + 2] = r;+ data[offset + 3] = 255;+ } else {+ data[offset] = r;+ data[offset + 1] = g;+ data[offset + 2] = b;+ data[offset + 3] = 255;+ }+ }+ }+ }+ }+ Pixel::NV12 => {+ fill_nv12_gradient(frame, info, phase);+ }+ _ => {+ fill_random_fallback(frame, info, frame_number);+ }+ }+}++fn fill_frame_counter(frame: &mut ffmpeg::frame::Video, info: &VideoInfo, frame_number: u64) {+ let width = info.width as usize;+ let height = info.height as usize;++ let frame_bytes = frame_number.to_le_bytes();++ match info.pixel_format {+ Pixel::BGRA | Pixel::RGBA => {+ let stride = frame.stride(0);+ let data = frame.data_mut(0);++ for y in 0..height {+ for x in 0..width {+ let intensity = if y < 64 && x < 256 {+ let byte_idx = x / 32;+ let bit_idx = (x % 32) / 4;+ if byte_idx < 8 {+ let byte = frame_bytes[byte_idx];+ if (byte >> bit_idx) & 1 == 1 { 255 } else { 0 }+ } else {+ 128+ }+ } else {+ ((frame_number % 256) as u8).wrapping_add(((x ^ y) & 0xFF) as u8)+ };++ let offset = y * stride + x * 4;+ if offset + 3 < data.len() {+ data[offset] = intensity;+ data[offset + 1] = intensity;+ data[offset + 2] = intensity;+ data[offset + 3] = 255;+ }+ }+ }+ }+ Pixel::NV12 => {+ fill_nv12_frame_counter(frame, info, frame_number, &frame_bytes);+ }+ _ => {+ fill_random_fallback(frame, info, frame_number);+ }+ }+}++fn fill_timestamp_overlay(frame: &mut ffmpeg::frame::Video, info: &VideoInfo, frame_number: u64) {+ fill_frame_counter(frame, info, frame_number);+}++fn fill_checkerboard(frame: &mut ffmpeg::frame::Video, info: &VideoInfo, frame_number: u64) {+ let width = info.width as usize;+ let height = info.height as usize;+ let check_size = 32;+ let offset = (frame_number % (check_size as u64 * 2)) as usize;++ match info.pixel_format {+ Pixel::BGRA | Pixel::RGBA => {+ let stride = frame.stride(0);+ let data = frame.data_mut(0);++ for y in 0..height {+ for x in 0..width {+ let check_x = (x + offset) / check_size;+ let check_y = y / check_size;+ let is_white = (check_x + check_y) % 2 == 0;+ let val = if is_white { 255 } else { 0 };++ let pixel_offset = y * stride + x * 4;+ if pixel_offset + 3 < data.len() {+ data[pixel_offset] = val;+ data[pixel_offset + 1] = val;+ data[pixel_offset + 2] = val;+ data[pixel_offset + 3] = 255;+ }+ }+ }+ }+ Pixel::NV12 => {+ fill_nv12_checkerboard(frame, info, check_size, offset);+ }+ _ => {+ fill_random_fallback(frame, info, frame_number);+ }+ }+}++fn fill_solid_color(frame: &mut ffmpeg::frame::Video, info: &VideoInfo, r: u8, g: u8, b: u8) {+ let width = info.width as usize;+ let height = info.height as usize;++ match info.pixel_format {+ Pixel::BGRA => {+ let stride = frame.stride(0);+ let data = frame.data_mut(0);++ for y in 0..height {+ for x in 0..width {+ let offset = y * stride + x * 4;+ if offset + 3 < data.len() {+ data[offset] = b;+ data[offset + 1] = g;+ data[offset + 2] = r;+ data[offset + 3] = 255;+ }+ }+ }+ }+ Pixel::RGBA => {+ let stride = frame.stride(0);+ let data = frame.data_mut(0);++ for y in 0..height {+ for x in 0..width {+ let offset = y * stride + x * 4;+ if offset + 3 < data.len() {+ data[offset] = r;+ data[offset + 1] = g;+ data[offset + 2] = b;+ data[offset + 3] = 255;+ }+ }+ }+ }+ Pixel::NV12 => {+ let y_val = rgb_to_y(r, g, b);+ let (u_val, v_val) = rgb_to_uv(r, g, b);++ let y_stride = frame.stride(0);+ let uv_stride = frame.stride(1);++ {+ let data = frame.data_mut(0);+ for y in 0..height {+ for x in 0..width {+ let offset = y * y_stride + x;+ if offset < data.len() {+ data[offset] = y_val;+ }+ }+ }+ }++ {+ let uv_data = frame.data_mut(1);+ for y in 0..(height / 2) {+ for x in 0..(width / 2) {+ let offset = y * uv_stride + x * 2;+ if offset + 1 < uv_data.len() {+ uv_data[offset] = u_val;+ uv_data[offset + 1] = v_val;+ }+ }+ }+ }+ }+ _ => {+ fill_random_fallback(frame, info, 0);+ }+ }+}++fn fill_random(frame: &mut ffmpeg::frame::Video, info: &VideoInfo, frame_number: u64) {+ fill_random_fallback(frame, info, frame_number);+}++fn fill_random_fallback(frame: &mut ffmpeg::frame::Video, _info: &VideoInfo, frame_number: u64) {+ for plane_idx in 0..frame.planes() {+ let data = frame.data_mut(plane_idx);+ for (i, byte) in data.iter_mut().enumerate() {+ *byte = ((i+ .wrapping_mul(17)+ .wrapping_add(plane_idx * 31)+ .wrapping_add(frame_number as usize))+ % 256) as u8;+ }+ }+}++fn fill_nv12_gradient(frame: &mut ffmpeg::frame::Video, info: &VideoInfo, phase: u8) {+ let width = info.width as usize;+ let height = info.height as usize;++ let y_stride = frame.stride(0);+ let uv_stride = frame.stride(1);++ {+ let y_data = frame.data_mut(0);+ for y in 0..height {+ for x in 0..width {+ let val = (((x * 255 / width) + (y * 255 / height)) / 2) as u8;+ let y_offset = y * y_stride + x;+ if y_offset < y_data.len() {+ y_data[y_offset] = val.wrapping_add(phase);+ }+ }+ }+ }++ {+ let uv_data = frame.data_mut(1);+ for y in 0..(height / 2) {+ for x in 0..(width / 2) {+ let uv_offset = y * uv_stride + x * 2;+ if uv_offset + 1 < uv_data.len() {+ uv_data[uv_offset] = 128;+ uv_data[uv_offset + 1] = 128;+ }+ }+ }+ }+}++fn fill_nv12_frame_counter(+ frame: &mut ffmpeg::frame::Video,+ info: &VideoInfo,+ frame_number: u64,+ frame_bytes: &[u8; 8],+) {+ let width = info.width as usize;+ let height = info.height as usize;++ let y_stride = frame.stride(0);+ let uv_stride = frame.stride(1);++ {+ let y_data = frame.data_mut(0);+ for y in 0..height {+ for x in 0..width {+ let intensity = if y < 64 && x < 256 {+ let byte_idx = x / 32;+ let bit_idx = (x % 32) / 4;+ if byte_idx < 8 {+ let byte = frame_bytes[byte_idx];+ if (byte >> bit_idx) & 1 == 1 { 235 } else { 16 }+ } else {+ 128+ }+ } else {+ ((frame_number % 220) as u8).wrapping_add(16)+ };++ let y_offset = y * y_stride + x;+ if y_offset < y_data.len() {+ y_data[y_offset] = intensity;+ }+ }+ }+ }++ {+ let uv_data = frame.data_mut(1);+ for y in 0..(height / 2) {+ for x in 0..(width / 2) {+ let uv_offset = y * uv_stride + x * 2;+ if uv_offset + 1 < uv_data.len() {+ uv_data[uv_offset] = 128;+ uv_data[uv_offset + 1] = 128;+ }+ }+ }+ }+}++fn fill_nv12_checkerboard(+ frame: &mut ffmpeg::frame::Video,+ info: &VideoInfo,+ check_size: usize,+ offset: usize,+) {+ let width = info.width as usize;+ let height = info.height as usize;++ let y_stride = frame.stride(0);+ let uv_stride = frame.stride(1);++ {+ let y_data = frame.data_mut(0);+ for y in 0..height {+ for x in 0..width {+ let check_x = (x + offset) / check_size;+ let check_y = y / check_size;+ let is_white = (check_x + check_y) % 2 == 0;+ let val = if is_white { 235 } else { 16 };++ let y_offset = y * y_stride + x;+ if y_offset < y_data.len() {+ y_data[y_offset] = val;+ }+ }+ }+ }++ {+ let uv_data = frame.data_mut(1);+ for y in 0..(height / 2) {+ for x in 0..(width / 2) {+ let uv_offset = y * uv_stride + x * 2;+ if uv_offset + 1 < uv_data.len() {+ uv_data[uv_offset] = 128;+ uv_data[uv_offset + 1] = 128;+ }+ }+ }+ }+}++fn rgb_to_y(r: u8, g: u8, b: u8) -> u8 {+ let y = 16.0 + (65.481 * f64::from(r) + 128.553 * f64::from(g) + 24.966 * f64::from(b)) / 255.0;+ y.clamp(16.0, 235.0) as u8+}++fn rgb_to_uv(r: u8, g: u8, b: u8) -> (u8, u8) {+ let u = 128.0 + (-37.797 * f64::from(r) - 74.203 * f64::from(g) + 112.0 * f64::from(b)) / 255.0;+ let v = 128.0 + (112.0 * f64::from(r) - 93.786 * f64::from(g) - 18.214 * f64::from(b)) / 255.0;+ (u.clamp(16.0, 240.0) as u8, v.clamp(16.0, 240.0) as u8)+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn test_rgb_to_yuv_black() {+ let y = rgb_to_y(0, 0, 0);+ let (u, v) = rgb_to_uv(0, 0, 0);+ assert_eq!(y, 16);+ assert_eq!(u, 128);+ assert_eq!(v, 128);+ }++ #[test]+ fn test_rgb_to_yuv_white() {+ let y = rgb_to_y(255, 255, 255);+ assert_eq!(y, 235);+ }++ #[test]+ fn test_video_info_creation() {+ let config = VideoTestConfig::fhd_1080p();+ let info = VideoInfo {+ pixel_format: config.pixel_format,+ width: config.width,+ height: config.height,+ time_base: FFRational(1, 1_000_000),+ frame_rate: FFRational(config.frame_rate as i32, 1),+ };++ assert_eq!(info.width, 1920);+ assert_eq!(info.height, 1080);+ assert_eq!(info.pixel_format, Pixel::NV12);+ }+}diff --git a/crates/recording/tests/synthetic_recording.rs b/crates/recording/tests/synthetic_recording.rsnew file mode 100644index 000000000..4911e253d--- /dev/null+++ b/crates/recording/tests/synthetic_recording.rs@@ -0,0 +1,531 @@+use cap_recording::test_sources::{+ AudioGenerator, AudioTestConfig, OutputFormat, RecordingValidator, SyncDetector, SyncMarker,+ SyncMarkerType, SyncTestConfig, TestConfig, TestPattern, VideoTestConfig,+};+use std::time::Duration;++#[test]+fn test_video_config_creation() {+ let video_config = VideoTestConfig {+ width: 1920,+ height: 1080,+ frame_rate: 30,+ pixel_format: ffmpeg::format::Pixel::NV12,+ pattern: TestPattern::SmpteColorBars,+ };++ assert_eq!(video_config.width, 1920);+ assert_eq!(video_config.height, 1080);+ assert_eq!(video_config.frame_rate, 30);+}++#[test]+fn test_video_config_builder_pattern() {+ let config = VideoTestConfig::default()+ .with_resolution(1280, 720)+ .with_frame_rate(60)+ .with_pixel_format(ffmpeg::format::Pixel::BGRA)+ .with_pattern(TestPattern::Checkerboard);++ assert_eq!(config.width, 1280);+ assert_eq!(config.height, 720);+ assert_eq!(config.frame_rate, 60);+}++#[test]+fn test_video_patterns_enum() {+ let patterns = [+ TestPattern::SmpteColorBars,+ TestPattern::ColorGradient,+ TestPattern::FrameCounter,+ TestPattern::Checkerboard,+ TestPattern::SolidColor { r: 255, g: 0, b: 0 },+ TestPattern::Random,+ ];++ for pattern in patterns {+ let config = VideoTestConfig::default().with_pattern(pattern);+ assert!(config.frame_rate > 0);+ }+}++#[test]+fn test_sync_event_generation() {+ let config = SyncTestConfig {+ video_fps: 30,+ audio_sample_rate: 48000,+ sync_interval_ms: 1000,+ duration: Duration::from_secs(5),+ };++ let events = config.generate_sync_events();++ assert_eq!(events.len(), 5);+ assert_eq!(events[0].expected_time_ms, 0.0);+ assert_eq!(events[1].expected_time_ms, 1000.0);+ assert_eq!(events[2].expected_time_ms, 2000.0);++ assert_eq!(events[0].frame_number, 0);+ assert_eq!(events[1].frame_number, 30);+ assert_eq!(events[2].frame_number, 60);++ assert_eq!(events[0].audio_sample, 0);+ assert_eq!(events[1].audio_sample, 48000);+}++#[test]+fn test_sync_detector_flash_detection() {+ let detector = SyncDetector::new(30, 48000);++ let bright_frame: Vec<u8> = vec![255; 1920 * 1080];+ assert!(detector.detect_flash_in_frame(&bright_frame, 1920, 1080));++ let dark_frame: Vec<u8> = vec![16; 1920 * 1080];+ assert!(!detector.detect_flash_in_frame(&dark_frame, 1920, 1080));++ let medium_frame: Vec<u8> = vec![128; 1920 * 1080];+ assert!(!detector.detect_flash_in_frame(&medium_frame, 1920, 1080));+}++#[test]+fn test_sync_detector_beep_detection() {+ let detector = SyncDetector::new(30, 48000);++ let loud_samples: Vec<f32> = vec![0.5; 4800];+ assert!(+ detector+ .detect_beep_in_audio(&loud_samples, 48000)+ .is_some()+ );++ let silent_samples: Vec<f32> = vec![0.0; 4800];+ assert!(+ detector+ .detect_beep_in_audio(&silent_samples, 48000)+ .is_none()+ );++ let quiet_samples: Vec<f32> = vec![0.1; 4800];+ assert!(+ detector+ .detect_beep_in_audio(&quiet_samples, 48000)+ .is_none()+ );+}++#[test]+fn test_sync_analysis() {+ use cap_recording::test_sources::{DetectedSyncEvent, SyncAnalysisResult};++ let events = vec![+ DetectedSyncEvent {+ expected_time_ms: 0.0,+ video_detected_ms: Some(0.0),+ audio_detected_ms: Some(5.0),+ offset_ms: 5.0,+ },+ DetectedSyncEvent {+ expected_time_ms: 1000.0,+ video_detected_ms: Some(1000.0),+ audio_detected_ms: Some(1010.0),+ offset_ms: 10.0,+ },+ DetectedSyncEvent {+ expected_time_ms: 2000.0,+ video_detected_ms: Some(2000.0),+ audio_detected_ms: Some(2015.0),+ offset_ms: 15.0,+ },+ ];++ let result = SyncAnalysisResult::new(events, 50.0);++ assert_eq!(result.average_offset_ms, 10.0);+ assert_eq!(result.max_offset_ms, 15.0);+ assert_eq!(result.min_offset_ms, 5.0);+ assert!(result.sync_ok);+ assert!(result.is_within_tolerance(50.0));+ assert!(!result.is_within_tolerance(10.0));+}++#[test]+fn test_validator_frame_sequence() {+ let config = TestConfig::default();+ let validator = RecordingValidator::new(&config);++ let sequential = vec![0, 1, 2, 3, 4, 5];+ let result = validator.verify_frame_sequence(&sequential);+ assert!(result.is_sequential);+ assert_eq!(result.dropped_count, 0);+ assert_eq!(result.duplicate_count, 0);++ let with_gap = vec![0, 1, 2, 5, 6, 7];+ let result = validator.verify_frame_sequence(&with_gap);+ assert!(!result.is_sequential);+ assert_eq!(result.dropped_count, 2);+ assert_eq!(result.gaps, vec![(3, 4)]);++ let with_duplicate = vec![0, 1, 2, 2, 3, 4];+ let result = validator.verify_frame_sequence(&with_duplicate);+ assert!(!result.is_sequential);+ assert_eq!(result.duplicate_count, 1);+}++#[test]+fn test_validator_expected_frame_count() {+ let config = TestConfig {+ video: Some(VideoTestConfig {+ width: 1920,+ height: 1080,+ frame_rate: 30,+ pixel_format: ffmpeg::format::Pixel::NV12,+ pattern: TestPattern::FrameCounter,+ }),+ audio: None,+ duration: Duration::from_secs(5),+ output_format: OutputFormat::Mp4,+ };++ let validator = RecordingValidator::new(&config);+ assert_eq!(validator.expected_frame_count(), 150);+}++#[test]+fn test_validation_result_summary() {+ use cap_recording::test_sources::ValidationResult;++ let result = ValidationResult {+ frame_count_ok: true,+ expected_frames: 150,+ actual_frames: 148,+ duration_ok: true,+ expected_duration: Duration::from_secs(5),+ actual_duration: Duration::from_secs_f64(4.93),+ av_sync_offset_ms: 12.5,+ av_sync_ok: true,+ dropped_frames: 2,+ fragment_integrity: true,+ fragments_checked: 2,+ fragments_valid: 2,+ errors: vec![],+ };++ assert!(result.is_valid());++ let summary = result.summary();+ assert!(summary.contains("148/150"));+ assert!(summary.contains("12.5ms"));+ assert!(summary.contains("Dropped frames: 2"));+}++#[test]+fn test_test_config_presets() {+ let common = cap_recording::test_sources::common_test_configs();+ assert!(!common.is_empty());++ for config in &common {+ assert!(config.video.is_some() || config.audio.is_some());+ assert!(config.duration.as_millis() > 0);+ }+}++#[test]+fn test_video_config_presets() {+ let fhd = VideoTestConfig::fhd_1080p();+ assert_eq!(fhd.width, 1920);+ assert_eq!(fhd.height, 1080);+ assert_eq!(fhd.frame_rate, 30);++ let uhd = VideoTestConfig::uhd_4k();+ assert_eq!(uhd.width, 3840);+ assert_eq!(uhd.height, 2160);+ assert_eq!(uhd.frame_rate, 30);++ let ultrawide = VideoTestConfig::ultrawide_1440();+ assert_eq!(ultrawide.width, 3440);+ assert_eq!(ultrawide.height, 1440);++ let macbook = VideoTestConfig::macbook_pro_16_promotion();+ assert_eq!(macbook.width, 3456);+ assert_eq!(macbook.height, 2234);+ assert_eq!(macbook.frame_rate, 120);+}++#[test]+fn test_audio_config_presets() {+ let mono = AudioTestConfig::broadcast_mono();+ assert_eq!(mono.sample_rate, 48000);+ assert_eq!(mono.channels, 1);++ let stereo = AudioTestConfig::broadcast_stereo();+ assert_eq!(stereo.sample_rate, 48000);+ assert_eq!(stereo.channels, 2);++ let surround = AudioTestConfig::surround_5_1();+ assert_eq!(surround.sample_rate, 48000);+ assert_eq!(surround.channels, 6);+}++#[test]+fn test_audio_generators() {+ let generators = [+ AudioGenerator::SineWave { frequency: 440.0 },+ AudioGenerator::Chirp {+ start_freq: 100.0,+ end_freq: 1000.0,+ },+ AudioGenerator::WhiteNoise,+ AudioGenerator::Silence,+ AudioGenerator::TimestampBeeps {+ beep_interval_ms: 1000,+ },+ AudioGenerator::Square { frequency: 440.0 },+ ];++ for generator in generators {+ let config = AudioTestConfig {+ sample_rate: 48000,+ channels: 2,+ sample_format: ffmpeg::format::Sample::F32(ffmpeg::format::sample::Type::Planar),+ generator,+ };++ assert_eq!(config.sample_rate, 48000);+ }+}++#[test]+fn test_output_formats() {+ let formats = [+ OutputFormat::Mp4,+ OutputFormat::FragmentedM4s {+ segment_duration: Duration::from_secs(3),+ },+ OutputFormat::OggOpus,+ ];++ for format in formats {+ let config = TestConfig {+ video: Some(VideoTestConfig::default()),+ audio: Some(AudioTestConfig::default()),+ duration: Duration::from_secs(1),+ output_format: format,+ };++ assert!(config.video.is_some());+ }+}++#[test]+fn test_sync_marker_types() {+ let video_marker = SyncMarker {+ marker_type: SyncMarkerType::VideoFlash,+ time_ms: 1000.0,+ frame_number: Some(30),+ sample_number: None,+ };+ assert_eq!(video_marker.marker_type, SyncMarkerType::VideoFlash);++ let audio_marker = SyncMarker {+ marker_type: SyncMarkerType::AudioBeep,+ time_ms: 1000.0,+ frame_number: None,+ sample_number: Some(48000),+ };+ assert_eq!(audio_marker.marker_type, SyncMarkerType::AudioBeep);++ let combined = SyncMarker {+ marker_type: SyncMarkerType::Combined,+ time_ms: 1000.0,+ frame_number: Some(30),+ sample_number: Some(48000),+ };+ assert_eq!(combined.marker_type, SyncMarkerType::Combined);+}++#[test]+fn test_time_conversions() {+ use cap_recording::test_sources::{+ frame_number_to_time_ms, sample_number_to_time_ms, time_ms_to_frame_number,+ time_ms_to_sample_number,+ };++ assert_eq!(frame_number_to_time_ms(30, 30), 1000.0);+ assert_eq!(frame_number_to_time_ms(60, 60), 1000.0);+ assert_eq!(frame_number_to_time_ms(0, 30), 0.0);++ assert_eq!(sample_number_to_time_ms(48000, 48000), 1000.0);+ assert_eq!(sample_number_to_time_ms(44100, 44100), 1000.0);++ assert_eq!(time_ms_to_frame_number(1000.0, 30), 30);+ assert_eq!(time_ms_to_frame_number(1000.0, 60), 60);++ assert_eq!(time_ms_to_sample_number(1000.0, 48000), 48000);+ assert_eq!(time_ms_to_sample_number(1000.0, 44100), 44100);+}++#[test]+fn test_sync_config_helpers() {+ let config = SyncTestConfig {+ video_fps: 30,+ audio_sample_rate: 48000,+ sync_interval_ms: 1000,+ duration: Duration::from_secs(5),+ };++ assert_eq!(config.frames_per_sync_interval(), 30);+ assert_eq!(config.samples_per_sync_interval(), 48000);+}++#[test]+fn test_file_size_estimation() {+ use cap_recording::test_sources::calculate_expected_file_size;++ let config = TestConfig {+ video: Some(VideoTestConfig::fhd_1080p()),+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration: Duration::from_secs(5),+ output_format: OutputFormat::Mp4,+ };++ let size = calculate_expected_file_size(&config);+ assert!(size > 0);+ assert!(size < 100_000_000);+}++#[test]+fn test_video_only_config() {+ let config = TestConfig {+ video: Some(VideoTestConfig::fhd_1080p()),+ audio: None,+ duration: Duration::from_secs(1),+ output_format: OutputFormat::Mp4,+ };++ let validator = RecordingValidator::new(&config);+ assert!(validator.expected_frame_count() > 0);+}++#[test]+fn test_audio_only_config() {+ let config = TestConfig {+ video: None,+ audio: Some(AudioTestConfig::broadcast_stereo()),+ duration: Duration::from_secs(1),+ output_format: OutputFormat::OggOpus,+ };++ let validator = RecordingValidator::new(&config);+ assert_eq!(validator.expected_frame_count(), 0);+}++#[test]+fn test_comprehensive_config_matrix() {+ let configs = cap_recording::test_sources::comprehensive_test_configs();++ assert!(configs.len() > 20, "Should have many comprehensive configs");++ let has_4k = configs.iter().any(|c| {+ c.video+ .as_ref()+ .map_or(false, |v| v.width == 3840 && v.height == 2160)+ });+ assert!(has_4k, "Should include 4K resolution");++ let has_ultrawide = configs.iter().any(|c| {+ c.video+ .as_ref()+ .map_or(false, |v| v.width == 3440 && v.height == 1440)+ });+ assert!(has_ultrawide, "Should include ultrawide resolution");++ let has_60fps = configs+ .iter()+ .any(|c| c.video.as_ref().map_or(false, |v| v.frame_rate >= 60));+ assert!(has_60fps, "Should include 60fps or higher");+}++#[test]+fn test_resolution_presets() {+ let hd = VideoTestConfig::hd_720p();+ assert_eq!(hd.width, 1280);+ assert_eq!(hd.height, 720);++ let qhd = VideoTestConfig::qhd_1440p();+ assert_eq!(qhd.width, 2560);+ assert_eq!(qhd.height, 1440);++ let webcam_hd = VideoTestConfig::webcam_hd();+ assert_eq!(webcam_hd.width, 1280);+ assert_eq!(webcam_hd.height, 720);+ assert_eq!(webcam_hd.frame_rate, 30);++ let webcam_4k = VideoTestConfig::webcam_4k();+ assert_eq!(webcam_4k.width, 3840);+ assert_eq!(webcam_4k.height, 2160);+}++#[test]+fn test_sync_detector_with_threshold() {+ let detector = SyncDetector::new(30, 48000)+ .with_flash_threshold(180)+ .with_beep_threshold(0.2);++ let borderline_frame: Vec<u8> = vec![190; 1920 * 1080];+ assert!(detector.detect_flash_in_frame(&borderline_frame, 1920, 1080));++ let below_threshold_frame: Vec<u8> = vec![170; 1920 * 1080];+ assert!(!detector.detect_flash_in_frame(&below_threshold_frame, 1920, 1080));+}++#[test]+fn test_empty_sync_analysis() {+ use cap_recording::test_sources::SyncAnalysisResult;++ let result = SyncAnalysisResult::new(vec![], 50.0);+ assert!(!result.sync_ok || result.events.is_empty());+}++#[test]+fn test_validation_result_with_errors() {+ use cap_recording::test_sources::ValidationResult;++ let result = ValidationResult {+ frame_count_ok: true,+ expected_frames: 150,+ actual_frames: 150,+ duration_ok: true,+ expected_duration: Duration::from_secs(5),+ actual_duration: Duration::from_secs(5),+ av_sync_offset_ms: 0.0,+ av_sync_ok: true,+ dropped_frames: 0,+ fragment_integrity: true,+ fragments_checked: 2,+ fragments_valid: 2,+ errors: vec!["Test error".to_string()],+ };++ assert!(!result.is_valid());+}++#[test]+fn test_frame_sequence_empty() {+ let config = TestConfig::default();+ let validator = RecordingValidator::new(&config);++ let empty: Vec<u64> = vec![];+ let result = validator.verify_frame_sequence(&empty);+ assert_eq!(result.total_frames, 0);+}++#[test]+fn test_frame_sequence_single() {+ let config = TestConfig::default();+ let validator = RecordingValidator::new(&config);++ let single = vec![0];+ let result = validator.verify_frame_sequence(&single);+ assert!(result.is_sequential);+ assert_eq!(result.total_frames, 1);+}diff --git a/logs.txt b/logs.txtnew file mode 100644index 000000000..c6780aad7--- /dev/null+++ b/logs.txt@@ -0,0 +1,592 @@+macbookuser@Macbooks-MacBook-Pro cap % cargo run --package cap-recording --example synthetic-test-runner --features test-utils -- full+ Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.43s+ Running `target/debug/examples/synthetic-test-runner full`+Running full test suite (comprehensive matrix)...++[1/60] 1280x720@24fps + NV12 + 48kHz + stereo+2025-12-29T20:44:25.362696Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_0/segments+[dash @ 0x152707db0] Opening '/tmp/cap-synthetic-tests/test_0/segments/init.mp4' for writing+2025-12-29T20:44:25.467660Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_0/segments segment_duration_secs=3+2025-12-29T20:44:25.491408Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_0/segments+[h264_videotoolbox @ 0x154104580] Color range not set for nv12. Using MPEG range.+[dash @ 0x152707db0] Opening '/tmp/cap-synthetic-tests/test_0/segments/segment_001.m4s.tmp' for writing+[dash @ 0x152707db0] Opening '/tmp/cap-synthetic-tests/test_0/segments/dash_manifest.mpd.tmp' for writing+[dash @ 0x152707db0] Opening '/tmp/cap-synthetic-tests/test_0/segments/segment_002.m4s.tmp' for writing+2025-12-29T20:44:30.335131Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 120 frames+2025-12-29T20:44:30.335229Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:30.335427Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:44:30.335493Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:30.866504Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x152707db0] Opening '/tmp/cap-synthetic-tests/test_0/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:44:30.883517Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_0/segments/segment_001.m4s with 20204 bytes, estimated duration 5.505107833s+2025-12-29T20:44:30.894416Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_0/segments/segment_002.m4s with 13478 bytes, estimated duration 3s+ ✓ Frame count: 120/120+ ✓ A/V sync: 0.0ms offset (< 50ms threshold)+ ✓ Fragment integrity: 2 segments OK+ Duration: 5.55s++[2/60] 1280x720@24fps + BGRA + 48kHz + stereo+2025-12-29T20:44:30.935795Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_1/segments+[dash @ 0x154105910] Opening '/tmp/cap-synthetic-tests/test_1/segments/init.mp4' for writing+2025-12-29T20:44:30.971776Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_1/segments segment_duration_secs=3+2025-12-29T20:44:30.980375Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_1/segments+[h264_videotoolbox @ 0x152707ac0] Color range not set for nv12. Using MPEG range.+[dash @ 0x154105910] Opening '/tmp/cap-synthetic-tests/test_1/segments/segment_001.m4s.tmp' for writing+[dash @ 0x154105910] Opening '/tmp/cap-synthetic-tests/test_1/segments/dash_manifest.mpd.tmp' for writing+[dash @ 0x154105910] Opening '/tmp/cap-synthetic-tests/test_1/segments/segment_002.m4s.tmp' for writing+2025-12-29T20:44:35.908747Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 120 frames+2025-12-29T20:44:35.908786Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:35.908848Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:44:35.908867Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:36.436850Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x154105910] Opening '/tmp/cap-synthetic-tests/test_1/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:44:36.451099Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_1/segments/segment_001.m4s with 2024520 bytes, estimated duration 5.501764459s+2025-12-29T20:44:36.456066Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_1/segments/segment_002.m4s with 1317560 bytes, estimated duration 3s+ ✓ Frame count: 120/120+ ✓ A/V sync: 0.0ms offset (< 50ms threshold)+ ✓ Fragment integrity: 2 segments OK+ Duration: 5.54s++[3/60] 1280x720@30fps + NV12 + 48kHz + stereo+2025-12-29T20:44:36.520825Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_2/segments+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_2/segments/init.mp4' for writing+2025-12-29T20:44:36.549777Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_2/segments segment_duration_secs=3+2025-12-29T20:44:36.558331Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_2/segments+[h264_videotoolbox @ 0x15400cbf0] Color range not set for nv12. Using MPEG range.+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_2/segments/segment_001.m4s.tmp' for writing+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_2/segments/dash_manifest.mpd.tmp' for writing+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_2/segments/segment_002.m4s.tmp' for writing+2025-12-29T20:44:41.499223Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 150 frames+2025-12-29T20:44:41.499321Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:41.499423Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:44:41.499451Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:42.026741Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_2/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:44:42.037693Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_2/segments/segment_001.m4s with 26850 bytes, estimated duration 5.506463375s+2025-12-29T20:44:42.042595Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_2/segments/segment_002.m4s with 15158 bytes, estimated duration 3s+ ✓ Frame count: 150/150+ ✓ A/V sync: 0.0ms offset (< 50ms threshold)+ ✓ Fragment integrity: 2 segments OK+ Duration: 5.54s++[4/60] 1280x720@30fps + BGRA + 48kHz + stereo+2025-12-29T20:44:42.078875Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_3/segments+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_3/segments/init.mp4' for writing+2025-12-29T20:44:42.115834Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_3/segments segment_duration_secs=3+2025-12-29T20:44:42.126372Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_3/segments+[h264_videotoolbox @ 0x15400d1d0] Color range not set for nv12. Using MPEG range.+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_3/segments/segment_001.m4s.tmp' for writing+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_3/segments/dash_manifest.mpd.tmp' for writing+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_3/segments/segment_002.m4s.tmp' for writing+2025-12-29T20:44:47.059608Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 150 frames+2025-12-29T20:44:47.059645Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:47.059706Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:44:47.059726Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:47.581481Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_3/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:44:47.596259Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_3/segments/segment_001.m4s with 2315928 bytes, estimated duration 5.503429s+2025-12-29T20:44:47.601273Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_3/segments/segment_002.m4s with 1306754 bytes, estimated duration 3s+ ✓ Frame count: 150/150+ ✓ A/V sync: 0.0ms offset (< 50ms threshold)+ ✓ Fragment integrity: 2 segments OK+ Duration: 5.54s++[5/60] 1280x720@60fps + NV12 + 48kHz + stereo+2025-12-29T20:44:47.662433Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_4/segments+[dash @ 0x152707d80] Opening '/tmp/cap-synthetic-tests/test_4/segments/init.mp4' for writing+2025-12-29T20:44:47.691576Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_4/segments segment_duration_secs=3+2025-12-29T20:44:47.702068Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_4/segments+[h264_videotoolbox @ 0x152708460] Color range not set for nv12. Using MPEG range.+[dash @ 0x152707d80] Opening '/tmp/cap-synthetic-tests/test_4/segments/segment_001.m4s.tmp' for writing+[dash @ 0x152707d80] Opening '/tmp/cap-synthetic-tests/test_4/segments/dash_manifest.mpd.tmp' for writing+[dash @ 0x152707d80] Opening '/tmp/cap-synthetic-tests/test_4/segments/segment_002.m4s.tmp' for writing+2025-12-29T20:44:52.655811Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 300 frames+2025-12-29T20:44:52.655847Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:52.655901Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:44:52.655921Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:53.166286Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x152707d80] Opening '/tmp/cap-synthetic-tests/test_4/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:44:53.182429Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_4/segments/segment_001.m4s with 50325 bytes, estimated duration 5.504508542s+2025-12-29T20:44:53.188394Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_4/segments/segment_002.m4s with 33611 bytes, estimated duration 3s+ ✓ Frame count: 300/300+ ✓ A/V sync: 0.0ms offset (< 50ms threshold)+ ✓ Fragment integrity: 2 segments OK+ Duration: 5.54s++[6/60] 1280x720@60fps + BGRA + 48kHz + stereo+2025-12-29T20:44:53.216503Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_5/segments+[dash @ 0x1526136d0] Opening '/tmp/cap-synthetic-tests/test_5/segments/init.mp4' for writing+2025-12-29T20:44:53.280729Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_5/segments segment_duration_secs=3+2025-12-29T20:44:53.291301Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_5/segments+[h264_videotoolbox @ 0x152614400] Color range not set for nv12. Using MPEG range.+[dash @ 0x1526136d0] Opening '/tmp/cap-synthetic-tests/test_5/segments/segment_001.m4s.tmp' for writing+[dash @ 0x1526136d0] Opening '/tmp/cap-synthetic-tests/test_5/segments/dash_manifest.mpd.tmp' for writing+[dash @ 0x1526136d0] Opening '/tmp/cap-synthetic-tests/test_5/segments/segment_002.m4s.tmp' for writing+2025-12-29T20:44:58.211865Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 300 frames+2025-12-29T20:44:58.211903Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:58.211964Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:44:58.211978Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:44:58.718244Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x1526136d0] Opening '/tmp/cap-synthetic-tests/test_5/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:44:58.733740Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_5/segments/segment_001.m4s with 3620296 bytes, estimated duration 5.502497792s+2025-12-29T20:44:58.737597Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_5/segments/segment_002.m4s with 2272858 bytes, estimated duration 3s+ ✓ Frame count: 296/300+ ✓ A/V sync: 0.0ms offset (< 50ms threshold)+ ✓ Fragment integrity: 2 segments OK+ Duration: 5.53s++[7/60] 1920x1080@24fps + NV12 + 48kHz + stereo+2025-12-29T20:44:58.795231Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_6/segments+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_6/segments/init.mp4' for writing+2025-12-29T20:44:58.833825Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_6/segments segment_duration_secs=3+2025-12-29T20:44:58.842360Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_6/segments+[h264_videotoolbox @ 0x15400cbf0] Color range not set for nv12. Using MPEG range.+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_6/segments/segment_001.m4s.tmp' for writing+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_6/segments/dash_manifest.mpd.tmp' for writing+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_6/segments/segment_002.m4s.tmp' for writing+2025-12-29T20:45:03.775931Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 120 frames+2025-12-29T20:45:03.775966Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:03.776022Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:45:03.776042Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:04.297409Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_6/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:45:04.311621Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_6/segments/segment_001.m4s with 39395 bytes, estimated duration 5.502722542s+2025-12-29T20:45:04.316570Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_6/segments/segment_002.m4s with 26327 bytes, estimated duration 3s+ ✓ Frame count: 120/120+ ✓ A/V sync: 0.0ms offset (< 50ms threshold)+ ✓ Fragment integrity: 2 segments OK+ Duration: 5.53s++[8/60] 1920x1080@24fps + BGRA + 48kHz + stereo+2025-12-29T20:45:04.352710Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_7/segments+[dash @ 0x152707d80] Opening '/tmp/cap-synthetic-tests/test_7/segments/init.mp4' for writing+2025-12-29T20:45:04.405973Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_7/segments segment_duration_secs=3+2025-12-29T20:45:04.414481Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_7/segments+[h264_videotoolbox @ 0x15270bf10] Color range not set for nv12. Using MPEG range.+[dash @ 0x152707d80] Opening '/tmp/cap-synthetic-tests/test_7/segments/segment_001.m4s.tmp' for writing+[dash @ 0x152707d80] Opening '/tmp/cap-synthetic-tests/test_7/segments/dash_manifest.mpd.tmp' for writing+[dash @ 0x152707d80] Opening '/tmp/cap-synthetic-tests/test_7/segments/segment_002.m4s.tmp' for writing+2025-12-29T20:45:09.337089Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 120 frames+2025-12-29T20:45:09.337128Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:09.337202Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:45:09.337216Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:09.855702Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x152707d80] Opening '/tmp/cap-synthetic-tests/test_7/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:45:09.876722Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_7/segments/segment_001.m4s with 4515774 bytes, estimated duration 5.506316958s+2025-12-29T20:45:09.880617Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_7/segments/segment_002.m4s with 2858738 bytes, estimated duration 3s+ ✓ Frame count: 120/120+ ✓ A/V sync: 0.0ms offset (< 50ms threshold)+ ✓ Fragment integrity: 2 segments OK+ Duration: 5.54s++[9/60] 1920x1080@30fps + NV12 + 48kHz + stereo+2025-12-29T20:45:09.982949Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_8/segments+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_8/segments/init.mp4' for writing+2025-12-29T20:45:10.018518Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_8/segments segment_duration_secs=3+2025-12-29T20:45:10.028013Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_8/segments+[h264_videotoolbox @ 0x15400cbf0] Color range not set for nv12. Using MPEG range.+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_8/segments/segment_001.m4s.tmp' for writing+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_8/segments/dash_manifest.mpd.tmp' for writing+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_8/segments/segment_002.m4s.tmp' for writing+2025-12-29T20:45:14.971253Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 150 frames+2025-12-29T20:45:14.971290Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:14.971343Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:45:14.971357Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:15.484394Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x15400c980] Opening '/tmp/cap-synthetic-tests/test_8/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:45:15.494162Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_8/segments/segment_001.m4s with 52473 bytes, estimated duration 5.501815083s+2025-12-29T20:45:15.498075Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_8/segments/segment_002.m4s with 29584 bytes, estimated duration 3s+ ✓ Frame count: 150/150+ ✓ A/V sync: 0.0ms offset (< 50ms threshold)+ ✓ Fragment integrity: 2 segments OK+ Duration: 5.53s++[10/60] 1920x1080@30fps + BGRA + 48kHz + stereo+2025-12-29T20:45:15.539799Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_9/segments+[dash @ 0x1526136d0] Opening '/tmp/cap-synthetic-tests/test_9/segments/init.mp4' for writing+2025-12-29T20:45:15.591037Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_9/segments segment_duration_secs=3+2025-12-29T20:45:15.600507Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_9/segments+[h264_videotoolbox @ 0x152614400] Color range not set for nv12. Using MPEG range.+[dash @ 0x1526136d0] Opening '/tmp/cap-synthetic-tests/test_9/segments/segment_001.m4s.tmp' for writing+[dash @ 0x1526136d0] Opening '/tmp/cap-synthetic-tests/test_9/segments/dash_manifest.mpd.tmp' for writing+[dash @ 0x1526136d0] Opening '/tmp/cap-synthetic-tests/test_9/segments/segment_002.m4s.tmp' for writing+2025-12-29T20:45:20.533401Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 150 frames+2025-12-29T20:45:20.533449Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:20.533535Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:45:20.533551Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:21.041314Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x1526136d0] Opening '/tmp/cap-synthetic-tests/test_9/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:45:21.063196Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_9/segments/segment_001.m4s with 5204656 bytes, estimated duration 5.502201791s+2025-12-29T20:45:21.068954Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_9/segments/segment_002.m4s with 2981951 bytes, estimated duration 3s+ ✓ Frame count: 150/150+ ✓ A/V sync: 0.0ms offset (< 50ms threshold)+ ✓ Fragment integrity: 2 segments OK+ Duration: 5.55s++[11/60] 1920x1080@60fps + NV12 + 48kHz + stereo+2025-12-29T20:45:21.179075Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_10/segments+2025-12-29T20:45:23.612144Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 129 dropped+2025-12-29T20:45:23.630867Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 130 dropped+2025-12-29T20:45:23.649587Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 131 dropped+2025-12-29T20:45:23.668119Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 132 dropped+2025-12-29T20:45:23.686953Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 133 dropped+2025-12-29T20:45:23.706275Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 134 dropped+2025-12-29T20:45:23.725510Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 135 dropped+2025-12-29T20:45:23.744089Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 136 dropped+2025-12-29T20:45:23.762669Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 137 dropped+2025-12-29T20:45:23.781163Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 138 dropped+2025-12-29T20:45:23.800109Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 139 dropped+2025-12-29T20:45:23.818728Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 140 dropped+2025-12-29T20:45:23.837038Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 141 dropped+2025-12-29T20:45:23.855361Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 142 dropped+2025-12-29T20:45:23.873772Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 143 dropped+2025-12-29T20:45:23.892566Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 144 dropped+2025-12-29T20:45:23.910988Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 145 dropped+2025-12-29T20:45:23.929237Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 146 dropped+2025-12-29T20:45:23.947496Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 147 dropped+2025-12-29T20:45:23.965847Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 148 dropped+2025-12-29T20:45:23.984447Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 149 dropped+2025-12-29T20:45:24.003286Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 150 dropped+2025-12-29T20:45:24.022027Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 151 dropped+2025-12-29T20:45:24.040483Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 152 dropped+2025-12-29T20:45:24.058954Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 153 dropped+2025-12-29T20:45:24.077374Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 154 dropped+2025-12-29T20:45:24.095759Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 155 dropped+2025-12-29T20:45:24.114217Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 156 dropped+2025-12-29T20:45:24.132650Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 157 dropped+2025-12-29T20:45:24.150899Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 158 dropped+2025-12-29T20:45:24.169179Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 159 dropped+2025-12-29T20:45:24.187508Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 160 dropped+2025-12-29T20:45:24.205873Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 161 dropped+2025-12-29T20:45:24.224251Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 162 dropped+2025-12-29T20:45:24.242765Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 163 dropped+2025-12-29T20:45:24.262102Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 164 dropped+2025-12-29T20:45:24.281146Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 165 dropped+2025-12-29T20:45:24.299436Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 166 dropped+2025-12-29T20:45:24.317815Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 167 dropped+2025-12-29T20:45:24.336184Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 168 dropped+2025-12-29T20:45:24.354584Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 169 dropped+2025-12-29T20:45:24.373123Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 170 dropped+2025-12-29T20:45:24.391682Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 171 dropped+2025-12-29T20:45:24.410086Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 172 dropped+2025-12-29T20:45:24.428459Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 173 dropped+2025-12-29T20:45:24.446846Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 174 dropped+2025-12-29T20:45:24.465255Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 175 dropped+2025-12-29T20:45:24.483592Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 176 dropped+2025-12-29T20:45:24.501949Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 177 dropped+2025-12-29T20:45:24.520330Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 178 dropped+2025-12-29T20:45:24.538545Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 179 dropped+2025-12-29T20:45:24.556879Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 180 dropped+2025-12-29T20:45:24.575533Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 181 dropped+2025-12-29T20:45:24.594141Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 182 dropped+2025-12-29T20:45:24.612994Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 183 dropped+2025-12-29T20:45:24.631941Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 184 dropped+2025-12-29T20:45:24.650952Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 185 dropped+2025-12-29T20:45:24.669488Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 186 dropped+2025-12-29T20:45:24.688141Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 187 dropped+2025-12-29T20:45:24.706552Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 188 dropped+2025-12-29T20:45:24.724983Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 189 dropped+2025-12-29T20:45:24.743756Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 190 dropped+2025-12-29T20:45:24.762283Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 191 dropped+2025-12-29T20:45:24.780957Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 192 dropped+2025-12-29T20:45:24.799472Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 193 dropped+2025-12-29T20:45:24.818023Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 194 dropped+2025-12-29T20:45:24.836654Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 195 dropped+2025-12-29T20:45:24.855093Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 196 dropped+2025-12-29T20:45:24.873531Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 197 dropped+2025-12-29T20:45:24.891938Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 198 dropped+2025-12-29T20:45:24.910334Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 199 dropped+2025-12-29T20:45:24.928785Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 200 dropped+2025-12-29T20:45:24.947227Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 201 dropped+2025-12-29T20:45:24.965473Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 202 dropped+2025-12-29T20:45:24.983755Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 203 dropped+2025-12-29T20:45:25.002258Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 204 dropped+2025-12-29T20:45:25.020664Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 205 dropped+2025-12-29T20:45:25.039243Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 206 dropped+2025-12-29T20:45:25.057612Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 207 dropped+2025-12-29T20:45:25.075855Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 208 dropped+2025-12-29T20:45:25.094236Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 209 dropped+2025-12-29T20:45:25.112645Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 210 dropped+2025-12-29T20:45:25.130996Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 211 dropped+2025-12-29T20:45:25.149328Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 212 dropped+2025-12-29T20:45:25.168000Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 213 dropped+2025-12-29T20:45:25.186545Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 214 dropped+2025-12-29T20:45:25.205290Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 215 dropped+2025-12-29T20:45:25.224265Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 216 dropped+2025-12-29T20:45:25.243021Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 217 dropped+2025-12-29T20:45:25.261947Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 218 dropped+2025-12-29T20:45:25.280268Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 219 dropped+2025-12-29T20:45:25.298515Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 220 dropped+2025-12-29T20:45:25.316891Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 221 dropped+2025-12-29T20:45:25.335218Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 222 dropped+2025-12-29T20:45:25.353574Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 223 dropped+2025-12-29T20:45:25.371944Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 224 dropped+2025-12-29T20:45:25.390251Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 225 dropped+2025-12-29T20:45:25.408596Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 226 dropped+2025-12-29T20:45:25.426911Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 227 dropped+2025-12-29T20:45:25.445520Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 228 dropped+2025-12-29T20:45:25.463755Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 229 dropped+2025-12-29T20:45:25.481980Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 230 dropped+2025-12-29T20:45:25.500473Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 231 dropped+2025-12-29T20:45:25.518776Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 232 dropped+2025-12-29T20:45:25.537088Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 233 dropped+2025-12-29T20:45:25.555346Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 234 dropped+2025-12-29T20:45:25.573618Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 235 dropped+2025-12-29T20:45:25.591900Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 236 dropped+2025-12-29T20:45:25.610186Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 237 dropped+2025-12-29T20:45:25.628492Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 238 dropped+2025-12-29T20:45:25.646792Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 239 dropped+2025-12-29T20:45:25.665086Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 240 dropped+2025-12-29T20:45:25.683366Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 241 dropped+2025-12-29T20:45:25.701752Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 242 dropped+2025-12-29T20:45:25.720075Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 243 dropped+2025-12-29T20:45:25.738361Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 244 dropped+2025-12-29T20:45:25.756647Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 245 dropped+2025-12-29T20:45:25.775072Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 246 dropped+2025-12-29T20:45:25.793422Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 247 dropped+2025-12-29T20:45:25.811972Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 248 dropped+2025-12-29T20:45:25.830285Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 249 dropped+2025-12-29T20:45:25.848593Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 250 dropped+2025-12-29T20:45:25.866862Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 251 dropped+2025-12-29T20:45:25.885130Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 252 dropped+2025-12-29T20:45:25.903384Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 253 dropped+2025-12-29T20:45:25.921621Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 254 dropped+2025-12-29T20:45:25.939813Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 255 dropped+2025-12-29T20:45:25.957999Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 256 dropped+2025-12-29T20:45:25.976198Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 257 dropped+2025-12-29T20:45:25.994396Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 258 dropped+2025-12-29T20:45:26.012785Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 259 dropped+2025-12-29T20:45:26.030974Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 260 dropped+2025-12-29T20:45:26.049426Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 261 dropped+2025-12-29T20:45:26.068146Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 262 dropped+2025-12-29T20:45:26.086557Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 263 dropped+2025-12-29T20:45:26.105459Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 264 dropped+2025-12-29T20:45:26.124208Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 265 dropped+2025-12-29T20:45:26.142839Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 266 dropped+2025-12-29T20:45:26.162010Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 267 dropped+2025-12-29T20:45:26.181229Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 268 dropped+2025-12-29T20:45:26.200883Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 269 dropped+2025-12-29T20:45:26.219648Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 270 dropped+2025-12-29T20:45:26.238382Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 271 dropped+2025-12-29T20:45:26.256964Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 272 dropped+2025-12-29T20:45:26.275691Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 273 dropped+2025-12-29T20:45:26.294319Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 274 dropped+2025-12-29T20:45:26.312686Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 275 dropped+2025-12-29T20:45:26.331073Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 276 dropped+2025-12-29T20:45:26.349604Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 277 dropped+2025-12-29T20:45:26.368077Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 278 dropped+2025-12-29T20:45:26.386342Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 279 dropped+2025-12-29T20:45:26.404602Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 280 dropped+2025-12-29T20:45:26.423076Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 281 dropped+2025-12-29T20:45:26.441370Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 282 dropped+2025-12-29T20:45:26.459746Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 283 dropped+2025-12-29T20:45:26.478202Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 284 dropped+2025-12-29T20:45:26.496731Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 285 dropped+2025-12-29T20:45:26.515230Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 286 dropped+2025-12-29T20:45:26.533616Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 287 dropped+2025-12-29T20:45:26.552205Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 288 dropped+2025-12-29T20:45:26.570961Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 289 dropped+2025-12-29T20:45:26.589282Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 290 dropped+2025-12-29T20:45:26.607945Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 291 dropped+2025-12-29T20:45:26.626248Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 292 dropped+2025-12-29T20:45:26.644649Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 293 dropped+2025-12-29T20:45:26.663044Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 294 dropped+2025-12-29T20:45:26.681303Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:26.681519Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 295 frames+2025-12-29T20:45:26.681540Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x152615d00] Opening '/tmp/cap-synthetic-tests/test_10/segments/init.mp4' for writing+2025-12-29T20:45:26.699522Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_10/segments segment_duration_secs=3+2025-12-29T20:45:26.710038Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_10/segments+[h264_videotoolbox @ 0x152615f70] Color range not set for nv12. Using MPEG range.+2025-12-29T20:45:26.725924Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+[dash @ 0x152615d00] Opening '/tmp/cap-synthetic-tests/test_10/segments/segment_001.m4s.tmp' for writing+2025-12-29T20:45:26.738524Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x152615d00] Opening '/tmp/cap-synthetic-tests/test_10/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:45:26.800976Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_10/segments/segment_001.m4s with 2321 bytes, estimated duration 5.559694875s+ ✗ FAILED: Validation failed: frame_count: 4/300; duration: 0.00s/5.00s+ Duration: 5.64s++[12/60] 1920x1080@60fps + BGRA + 48kHz + stereo+2025-12-29T20:45:26.829294Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_11/segments+2025-12-29T20:45:30.153386Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 129 dropped+2025-12-29T20:45:30.178778Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 130 dropped+2025-12-29T20:45:30.203835Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 131 dropped+2025-12-29T20:45:30.228771Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 132 dropped+2025-12-29T20:45:30.253975Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 133 dropped+2025-12-29T20:45:30.278824Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 134 dropped+2025-12-29T20:45:30.303055Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 135 dropped+2025-12-29T20:45:30.327606Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 136 dropped+2025-12-29T20:45:30.352301Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 137 dropped+2025-12-29T20:45:30.377116Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 138 dropped+2025-12-29T20:45:30.401194Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 139 dropped+2025-12-29T20:45:30.425719Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 140 dropped+2025-12-29T20:45:30.450152Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 141 dropped+2025-12-29T20:45:30.475690Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 142 dropped+2025-12-29T20:45:30.500384Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 143 dropped+2025-12-29T20:45:30.525048Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 144 dropped+2025-12-29T20:45:30.550018Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 145 dropped+2025-12-29T20:45:30.574233Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 146 dropped+2025-12-29T20:45:30.598419Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 147 dropped+2025-12-29T20:45:30.622850Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 148 dropped+2025-12-29T20:45:30.647508Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 149 dropped+2025-12-29T20:45:30.672405Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 150 dropped+2025-12-29T20:45:30.697059Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 151 dropped+2025-12-29T20:45:30.721348Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 152 dropped+2025-12-29T20:45:30.745589Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 153 dropped+2025-12-29T20:45:30.769881Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 154 dropped+2025-12-29T20:45:30.794895Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 155 dropped+2025-12-29T20:45:30.819274Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 156 dropped+2025-12-29T20:45:30.843615Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 157 dropped+2025-12-29T20:45:30.867899Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 158 dropped+2025-12-29T20:45:30.892471Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 159 dropped+2025-12-29T20:45:30.916780Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 160 dropped+2025-12-29T20:45:30.941034Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 161 dropped+2025-12-29T20:45:30.965259Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 162 dropped+2025-12-29T20:45:30.989593Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 163 dropped+2025-12-29T20:45:31.014081Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 164 dropped+2025-12-29T20:45:31.038499Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 165 dropped+2025-12-29T20:45:31.062660Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 166 dropped+2025-12-29T20:45:31.087061Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 167 dropped+2025-12-29T20:45:31.111675Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 168 dropped+2025-12-29T20:45:31.135815Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 169 dropped+2025-12-29T20:45:31.159937Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 170 dropped+2025-12-29T20:45:31.184532Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 171 dropped+2025-12-29T20:45:31.209083Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 172 dropped+2025-12-29T20:45:31.233523Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 173 dropped+2025-12-29T20:45:31.257690Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 174 dropped+2025-12-29T20:45:31.281956Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 175 dropped+2025-12-29T20:45:31.306129Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 176 dropped+2025-12-29T20:45:31.330295Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 177 dropped+2025-12-29T20:45:31.354574Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 178 dropped+2025-12-29T20:45:31.378946Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 179 dropped+2025-12-29T20:45:31.402961Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 180 dropped+2025-12-29T20:45:31.427321Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 181 dropped+2025-12-29T20:45:31.451626Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 182 dropped+2025-12-29T20:45:31.476316Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 183 dropped+2025-12-29T20:45:31.500826Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 184 dropped+2025-12-29T20:45:31.525400Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 185 dropped+2025-12-29T20:45:31.549658Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 186 dropped+2025-12-29T20:45:31.574178Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 187 dropped+2025-12-29T20:45:31.598454Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 188 dropped+2025-12-29T20:45:31.622475Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 189 dropped+2025-12-29T20:45:31.646555Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 190 dropped+2025-12-29T20:45:31.670670Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 191 dropped+2025-12-29T20:45:31.694958Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 192 dropped+2025-12-29T20:45:31.719142Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 193 dropped+2025-12-29T20:45:31.742995Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 194 dropped+2025-12-29T20:45:31.766822Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 195 dropped+2025-12-29T20:45:31.790845Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 196 dropped+2025-12-29T20:45:31.814761Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 197 dropped+2025-12-29T20:45:31.839357Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 198 dropped+2025-12-29T20:45:31.863430Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 199 dropped+2025-12-29T20:45:31.887703Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 200 dropped+2025-12-29T20:45:31.911708Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 201 dropped+2025-12-29T20:45:31.935847Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 202 dropped+2025-12-29T20:45:31.960001Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 203 dropped+2025-12-29T20:45:31.984349Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 204 dropped+2025-12-29T20:45:32.008660Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 205 dropped+2025-12-29T20:45:32.032859Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 206 dropped+2025-12-29T20:45:32.056962Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 207 dropped+2025-12-29T20:45:32.081254Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 208 dropped+2025-12-29T20:45:32.105488Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 209 dropped+2025-12-29T20:45:32.129801Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 210 dropped+2025-12-29T20:45:32.154199Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 211 dropped+2025-12-29T20:45:32.178558Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 212 dropped+2025-12-29T20:45:32.202723Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 213 dropped+2025-12-29T20:45:32.226897Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 214 dropped+2025-12-29T20:45:32.251120Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 215 dropped+2025-12-29T20:45:32.275490Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 216 dropped+2025-12-29T20:45:32.299789Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 217 dropped+2025-12-29T20:45:32.324387Z WARN {task="synthetic-video-generator"}: cap_recording::test_sources::video: Video frame channel full, frame 218 dropped+2025-12-29T20:45:32.330831Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:32.348810Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 219 frames+2025-12-29T20:45:32.348861Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x154105910] Opening '/tmp/cap-synthetic-tests/test_11/segments/init.mp4' for writing+2025-12-29T20:45:32.368406Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_11/segments segment_duration_secs=3+2025-12-29T20:45:32.379959Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_11/segments+[h264_videotoolbox @ 0x154109ce0] Color range not set for nv12. Using MPEG range.+[dash @ 0x154105910] Opening '/tmp/cap-synthetic-tests/test_11/segments/segment_001.m4s.tmp' for writing+2025-12-29T20:45:32.479681Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:45:32.485708Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x154105910] Opening '/tmp/cap-synthetic-tests/test_11/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:45:32.562163Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_11/segments/segment_001.m4s with 812670 bytes, estimated duration 5.656708584s+ ✗ FAILED: Validation failed: frame_count: 7/300; duration: 3.00s/5.00s+ Duration: 5.74s++[13/60] 2560x1440@24fps + NV12 + 48kHz + stereo+2025-12-29T20:45:32.663096Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_12/segments+[dash @ 0x142604a00] Opening '/tmp/cap-synthetic-tests/test_12/segments/init.mp4' for writing+2025-12-29T20:45:32.713990Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_12/segments segment_duration_secs=3+2025-12-29T20:45:32.725210Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_12/segments+[h264_videotoolbox @ 0x142604d90] Color range not set for nv12. Using MPEG range.+[dash @ 0x142604a00] Opening '/tmp/cap-synthetic-tests/test_12/segments/segment_001.m4s.tmp' for writing+[dash @ 0x142604a00] Opening '/tmp/cap-synthetic-tests/test_12/segments/dash_manifest.mpd.tmp' for writing+[dash @ 0x142604a00] Opening '/tmp/cap-synthetic-tests/test_12/segments/segment_002.m4s.tmp' for writing+2025-12-29T20:45:37.656119Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 120 frames+2025-12-29T20:45:37.656165Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:37.656289Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:45:37.656369Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:38.165698Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x142604a00] Opening '/tmp/cap-synthetic-tests/test_12/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:45:38.192760Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_12/segments/segment_001.m4s with 65749 bytes, estimated duration 5.503251958s+2025-12-29T20:45:38.198261Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_12/segments/segment_002.m4s with 41843 bytes, estimated duration 3s+ ✓ Frame count: 116/120+ ✓ A/V sync: 0.0ms offset (< 50ms threshold)+ ✓ Fragment integrity: 2 segments OK+ Duration: 5.56s++[14/60] 2560x1440@24fps + BGRA + 48kHz + stereo+2025-12-29T20:45:38.282698Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_13/segments+2025-12-29T20:45:43.627273Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 120 frames+2025-12-29T20:45:43.627327Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x154109200] Opening '/tmp/cap-synthetic-tests/test_13/segments/init.mp4' for writing+2025-12-29T20:45:43.650089Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_13/segments segment_duration_secs=3+2025-12-29T20:45:43.660642Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_13/segments+[h264_videotoolbox @ 0x154109a50] Color range not set for nv12. Using MPEG range.+[dash @ 0x154109200] Opening '/tmp/cap-synthetic-tests/test_13/segments/segment_001.m4s.tmp' for writing+2025-12-29T20:45:43.704935Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:45:43.705939Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:43.784588Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x154109200] Opening '/tmp/cap-synthetic-tests/test_13/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:45:43.792874Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_13/segments/segment_001.m4s with 867238 bytes, estimated duration 5.502305209s+ ✗ FAILED: Validation failed: frame_count: 4/120; duration: 7.00s/5.00s+ Duration: 5.52s++[15/60] 2560x1440@30fps + NV12 + 48kHz + stereo+2025-12-29T20:45:43.882650Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_14/segments+[dash @ 0x142604580] Opening '/tmp/cap-synthetic-tests/test_14/segments/init.mp4' for writing+2025-12-29T20:45:43.933409Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_14/segments segment_duration_secs=3+2025-12-29T20:45:43.941943Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_14/segments+[h264_videotoolbox @ 0x15270b9b0] Color range not set for nv12. Using MPEG range.+[dash @ 0x142604580] Opening '/tmp/cap-synthetic-tests/test_14/segments/segment_001.m4s.tmp' for writing+2025-12-29T20:45:48.895947Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 150 frames+2025-12-29T20:45:48.895993Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:48.896084Z WARN {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Segmented muxer frame drop rate exceeds 5% threshold frames=29 drops=118 drop_rate_pct="80.3%" total_frames=29 total_drops=118+2025-12-29T20:45:48.896112Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:45:48.896764Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:49.384405Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x142604580] Opening '/tmp/cap-synthetic-tests/test_14/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:45:49.402142Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_14/segments/segment_001.m4s with 29431 bytes, estimated duration 5.5031265s+ ✗ FAILED: Validation failed: frame_count: 44/150; duration: 7.00s/5.00s+ Duration: 5.54s++[16/60] 2560x1440@30fps + BGRA + 48kHz + stereo+2025-12-29T20:45:49.463604Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_15/segments+2025-12-29T20:45:54.965321Z INFO {task="capture-video"}: cap_recording::output_pipeline::core: Task finished successfully+2025-12-29T20:45:54.981968Z INFO {task="synthetic-video-generator"}: cap_recording::test_sources::video: Synthetic video generator finished after 126 frames+2025-12-29T20:45:54.982004Z INFO {task="synthetic-video-generator"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x152711a00] Opening '/tmp/cap-synthetic-tests/test_15/segments/init.mp4' for writing+2025-12-29T20:45:54.999702Z INFO {task="mux-video"}: cap_enc_ffmpeg::mux::segmented_stream: Initialized segmented video encoder with FFmpeg DASH muxer (init.mp4 + m4s segments) path=/tmp/cap-synthetic-tests/test_15/segments segment_duration_secs=3+2025-12-29T20:45:55.010168Z INFO {task="mux-video"}: cap_recording::output_pipeline::ffmpeg: Started segmented video encoder path=/tmp/cap-synthetic-tests/test_15/segments+[h264_videotoolbox @ 0x152712250] Color range not set for nv12. Using MPEG range.+[dash @ 0x152711a00] Opening '/tmp/cap-synthetic-tests/test_15/segments/segment_001.m4s.tmp' for writing+2025-12-29T20:45:55.052888Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: mux-video stream ended (rx closed)+2025-12-29T20:45:55.055307Z INFO {task="mux-video"}: cap_recording::output_pipeline::core: Task finished successfully+[dash @ 0x152711a00] Opening '/tmp/cap-synthetic-tests/test_15/segments/dash_manifest.mpd.tmp' for writing+2025-12-29T20:45:55.148944Z INFO cap_enc_ffmpeg::mux::segmented_stream: Recovered orphaned segment /tmp/cap-synthetic-tests/test_15/segments/segment_001.m4s with 1029910 bytes, estimated duration 5.591957125s+ ✗ FAILED: Validation failed: frame_count: 5/150; duration: 7.00s/5.00s+ Duration: 5.70s++[17/60] 2560x1440@60fps + NV12 + 48kHz + stereo+2025-12-29T20:45:55.236837Z INFO cap_recording::output_pipeline::core: Built pipeline for output /tmp/cap-synthetic-tests/test_16/segments+^[^[^C\ No newline at end of file