Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

style(crates): format h264 encoder and output pipeline

Richie McIlroy76680386441d
diff --git a/crates/enc-ffmpeg/src/video/h264_packet.rs b/crates/enc-ffmpeg/src/video/h264_packet.rs
index cc7c9f02b..51cded8c6 100644
--- a/crates/enc-ffmpeg/src/video/h264_packet.rs
+++ b/crates/enc-ffmpeg/src/video/h264_packet.rs
@@ -207,22 +207,14 @@ impl H264PacketEncoder {
let rate = tb.denominator() as f64 / tb.numerator() as f64;
let pts = (timestamp.as_secs_f64() * rate).round() as i64;
let first_pts = *self.first_pts.get_or_insert(pts);
- let pts = normalize_input_pts(
- pts - first_pts,
- self.last_frame_pts,
- tb,
- self.frame_rate,
- );
+ let pts =
+ normalize_input_pts(pts - first_pts, self.last_frame_pts, tb, self.frame_rate);
self.last_frame_pts = Some(pts);
frame.set_pts(Some(pts));
} else if let Some(pts) = frame.pts() {
let first_pts = *self.first_pts.get_or_insert(pts);
- let pts = normalize_input_pts(
- pts - first_pts,
- self.last_frame_pts,
- tb,
- self.frame_rate,
- );
+ let pts =
+ normalize_input_pts(pts - first_pts, self.last_frame_pts, tb, self.frame_rate);
self.last_frame_pts = Some(pts);
frame.set_pts(Some(pts));
} else {
diff --git a/crates/recording/src/output_pipeline/core.rs b/crates/recording/src/output_pipeline/core.rs
index 07982ee98..42390d899 100644
--- a/crates/recording/src/output_pipeline/core.rs
+++ b/crates/recording/src/output_pipeline/core.rs
@@ -201,10 +201,12 @@ pub(crate) async fn apply_video_start_gate(
// the actual capture time after the trim, not the pre-trim buffer start.
// Without this, the editor's mic_offset = display_start - mic_start equals
// trim_duration and causes it to skip that same duration a second time.
- let trim_duration = Duration::from_nanos(
- trim_samples as u64 * 1_000_000_000 / sample_rate as u64,
- );
- VideoStartGateAction::UseFrame(AudioFrame::new(trimmed, frame.timestamp + trim_duration))
+ let trim_duration =
+ Duration::from_nanos(trim_samples as u64 * 1_000_000_000 / sample_rate as u64);
+ VideoStartGateAction::UseFrame(AudioFrame::new(
+ trimmed,
+ frame.timestamp + trim_duration,
+ ))
}
None => {
warn!(
@@ -4725,8 +4727,7 @@ mod tests {
new_frame
.timestamp
.signed_duration_since_secs(master_clock.timestamps()),
- expected_ts
- .signed_duration_since_secs(master_clock.timestamps()),
+ expected_ts.signed_duration_since_secs(master_clock.timestamps()),
"gate UseFrame timestamp must be advanced past the trimmed samples"
);
}