Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
test(export): add audio_frame_budget monotonic budget test
Richie McIlroyc63147ec4c00
diff --git a/crates/export/src/mp4.rs b/crates/export/src/mp4.rsindex 8916867bd..8640a3053 100644--- a/crates/export/src/mp4.rs+++ b/crates/export/src/mp4.rs@@ -755,6 +755,30 @@ mod tests {}}+ // Drives the SAME `audio_frame_budget` the encoder loop uses, so it guards the+ // real arithmetic: each frame's PTS equals the previous frame's end (gapless,+ // non-overlapping) and the cursor advances exactly to the duration budget — i.e.+ // audio length stays anchored to the video frame grid with no drift. Read+ // alignment of the source PCM to presentation time is covered by the+ // export_audio_* tests in crates/editor/src/audio.rs.+ #[test]+ fn audio_frame_budget_is_monotonic_and_contiguous() {+ let sample_rate = u64::from(AudioRenderer::SAMPLE_RATE);++ for fps in [24u64, 30, 60] {+ let frames = fps * 3;+ let mut cursor = 0u64;+ for n in 0..frames {+ let (pts, samples) = audio_frame_budget(n, sample_rate, fps, cursor)+ .expect("a normal-rate frame always has a budget");+ assert_eq!(pts as u64, cursor, "fps {fps} frame {n}: pts == prior end");+ assert!(samples > 0, "fps {fps} frame {n}: frame must carry samples");+ cursor = pts as u64 + samples as u64;+ }+ assert_eq!(cursor, (frames * sample_rate) / fps);+ }+ }+#[test]fn fill_nv12_frame_preserves_data_layout() {ffmpeg::init().unwrap();