Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

clippyyyyy

Richie McIlroy9e0c7445b5eb
diff --git a/apps/desktop/src-tauri/src/captions.rs b/apps/desktop/src-tauri/src/captions.rs
index 15a953ba5..148097146 100644
--- a/apps/desktop/src-tauri/src/captions.rs
+++ b/apps/desktop/src-tauri/src/captions.rs
@@ -586,8 +586,8 @@ fn process_with_whisper(
}
log::info!("First 20 audio samples:");
- for i in 0..audio_data_f32.len().min(20) {
- log::info!(" Sample[{}] = {:.6}", i, audio_data_f32[i]);
+ for (i, sample) in audio_data_f32.iter().take(20).enumerate() {
+ log::info!(" Sample[{i}] = {sample:.6}");
}
}
@@ -635,7 +635,7 @@ fn process_with_whisper(
.full_n_tokens(i)
.map_err(|e| format!("Failed to get token count: {e}"))?;
- log::info!(" Segment {} has {} tokens", i, num_tokens);
+ log::info!(" Segment {i} has {num_tokens} tokens");
let mut current_word = String::new();
let mut word_start: Option<f32> = None;
@@ -1066,7 +1066,7 @@ fn start_whisperx_server(
fn transcribe_with_server(
server: &mut WhisperXServer,
- audio_path: &PathBuf,
+ audio_path: &std::path::Path,
model_size: &str,
language: &str,
) -> Result<CaptionData, String> {
@@ -1083,8 +1083,8 @@ fn transcribe_with_server(
log::info!("Sending transcription request to WhisperX server");
- writeln!(server.stdin, "{}", request.to_string())
- .map_err(|e| format!("Failed to send request to server: {}", e))?;
+ writeln!(server.stdin, "{request}")
+ .map_err(|e| format!("Failed to send request to server: {e}"))?;
server
.stdin
.flush()
diff --git a/apps/desktop/src-tauri/src/export.rs b/apps/desktop/src-tauri/src/export.rs
index 9b1d1c461..a342d1776 100644
--- a/apps/desktop/src-tauri/src/export.rs
+++ b/apps/desktop/src-tauri/src/export.rs
@@ -90,14 +90,12 @@ pub struct ExportEstimates {
pub estimated_size_mb: f64,
}
-// This will need to be refactored at some point to be more accurate.
#[tauri::command]
#[specta::specta]
#[instrument]
pub async fn get_export_estimates(
path: PathBuf,
- resolution: XY<u32>,
- fps: u32,
+ settings: ExportSettings,
) -> Result<ExportEstimates, String> {
let metadata = get_video_metadata(path.clone()).await?;
@@ -109,38 +107,56 @@ pub async fn get_export_estimates(
metadata.duration
};
- let (width, height) = (resolution.x, resolution.y);
-
- let base_bitrate = if width <= 1280 && height <= 720 {
- 4_000_000.0
- } else if width <= 1920 && height <= 1080 {
- 8_000_000.0
- } else if width <= 2560 && height <= 1440 {
- 14_000_000.0
- } else {
- 20_000_000.0
+ let (resolution, fps) = match &settings {
+ ExportSettings::Mp4(s) => (s.resolution_base, s.fps),
+ ExportSettings::Gif(s) => (s.resolution_base, s.fps),
};
- let fps_factor = (fps as f64) / 30.0;
- let video_bitrate = base_bitrate * fps_factor;
-
- let audio_bitrate = 192_000.0;
-
- let total_bitrate = video_bitrate + audio_bitrate;
+ let (width, height) = (resolution.x, resolution.y);
+ let total_pixels = (width * height) as f64;
+ let fps_f64 = fps as f64;
+ let total_frames = (duration_seconds * fps_f64).ceil();
+
+ let (estimated_size_mb, time_factor) = match &settings {
+ ExportSettings::Mp4(mp4_settings) => {
+ let bits_per_pixel = mp4_settings.compression.bits_per_pixel() as f64;
+ let video_bitrate = total_pixels * bits_per_pixel * fps_f64;
+ let audio_bitrate = 192_000.0;
+ let total_bitrate = video_bitrate + audio_bitrate;
+ let size_mb = (total_bitrate * duration_seconds) / (8.0 * 1024.0 * 1024.0);
+
+ let base_time_factor = match (width, height) {
+ (w, h) if w <= 1280 && h <= 720 => 0.35,
+ (w, h) if w <= 1920 && h <= 1080 => 0.50,
+ (w, h) if w <= 2560 && h <= 1440 => 0.65,
+ _ => 0.80,
+ };
+
+ let compression_factor = match mp4_settings.compression {
+ cap_export::mp4::ExportCompression::Minimal => 1.0,
+ cap_export::mp4::ExportCompression::Social => 1.1,
+ cap_export::mp4::ExportCompression::Web => 1.15,
+ cap_export::mp4::ExportCompression::Potato => 1.2,
+ };
+
+ (size_mb, base_time_factor * compression_factor)
+ }
+ ExportSettings::Gif(_) => {
+ let bytes_per_frame = total_pixels * 0.5;
+ let size_mb = (bytes_per_frame * total_frames) / (1024.0 * 1024.0);
- let estimated_size_mb = (total_bitrate * duration_seconds) / (8.0 * 1024.0 * 1024.0);
+ let base_time_factor = match (width, height) {
+ (w, h) if w <= 1280 && h <= 720 => 0.8,
+ (w, h) if w <= 1920 && h <= 1080 => 1.2,
+ _ => 1.5,
+ };
- let base_factor = match (width, height) {
- (w, h) if w <= 1280 && h <= 720 => 0.43,
- (w, h) if w <= 1920 && h <= 1080 => 0.64,
- (w, h) if w <= 2560 && h <= 1440 => 0.75,
- _ => 0.86,
+ (size_mb, base_time_factor)
+ }
};
- let processing_time = duration_seconds * base_factor * fps_factor;
- let overhead_time = 0.0;
-
- let estimated_time_seconds = processing_time + overhead_time;
+ let fps_factor = fps_f64 / 30.0;
+ let estimated_time_seconds = duration_seconds * time_factor * fps_factor;
Ok(ExportEstimates {
duration_seconds,
diff --git a/apps/desktop/src/routes/editor/ExportDialog.tsx b/apps/desktop/src/routes/editor/ExportDialog.tsx
index ba88a91f1..6d771e54a 100644
--- a/apps/desktop/src/routes/editor/ExportDialog.tsx
+++ b/apps/desktop/src/routes/editor/ExportDialog.tsx
@@ -236,20 +236,36 @@ export function ExportDialog() {
};
const exportEstimates = createQuery(() => ({
- // prevents flicker when modifying settings
placeholderData: keepPreviousData,
queryKey: [
"exportEstimates",
{
+ format: settings.format,
resolution: {
x: settings.resolution.width,
y: settings.resolution.height,
},
fps: settings.fps,
+ compression: settings.compression,
},
] as const,
- queryFn: ({ queryKey: [_, { resolution, fps }] }) =>
- commands.getExportEstimates(projectPath, resolution, fps),
+ queryFn: ({ queryKey: [_, { format, resolution, fps, compression }] }) => {
+ const exportSettings =
+ format === "Mp4"
+ ? {
+ format: "Mp4" as const,
+ fps,
+ resolution_base: resolution,
+ compression,
+ }
+ : {
+ format: "Gif" as const,
+ fps,
+ resolution_base: resolution,
+ quality: null,
+ };
+ return commands.getExportEstimates(projectPath, exportSettings);
+ },
}));
const exportButtonIcon: Record<"file" | "clipboard" | "link", JSX.Element> = {
@@ -737,7 +753,7 @@ export function ExportDialog() {
</div>
</div>
{/* Frame rate */}
- <div class="overflow-hidden relative p-4 rounded-xl dark:bg-gray-2 bg-gray-3">
+ <div class="p-4 rounded-xl dark:bg-gray-2 bg-gray-3">
<div class="flex flex-col gap-3">
<h3 class="text-gray-12">Frame rate</h3>
<KSelect<{ label: string; value: number }>
@@ -752,13 +768,13 @@ export function ExportDialog() {
: FPS_OPTIONS
).find((opt) => opt.value === settings.fps)}
onChange={(option) => {
- const value =
- option?.value ?? (settings.format === "Gif" ? 10 : 30);
+ if (!option) return;
trackEvent("export_fps_changed", {
- fps: value,
+ fps: option.value,
});
- setSettings("fps", value);
+ setSettings("fps", option.value);
}}
+ disallowEmptySelection
itemComponent={(props) => (
<MenuItem<typeof KSelect.Item>
as={KSelect.Item}
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index fcce4eb7b..b7b805ec9 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -77,8 +77,8 @@ async getCurrentRecording() : Promise<JsonValue<CurrentRecording | null>> {
async exportVideo(projectPath: string, progress: TAURI_CHANNEL<FramesRendered>, settings: ExportSettings) : Promise<string> {
return await TAURI_INVOKE("export_video", { projectPath, progress, settings });
},
-async getExportEstimates(path: string, resolution: XY<number>, fps: number) : Promise<ExportEstimates> {
- return await TAURI_INVOKE("get_export_estimates", { path, resolution, fps });
+async getExportEstimates(path: string, settings: ExportSettings) : Promise<ExportEstimates> {
+ return await TAURI_INVOKE("get_export_estimates", { path, settings });
},
async copyFileToPath(src: string, dst: string) : Promise<null> {
return await TAURI_INVOKE("copy_file_to_path", { src, dst });
diff --git a/crates/export/examples/export-cli.rs b/crates/export/examples/export-cli.rs
index f890a87d7..ea37ddd1e 100644
--- a/crates/export/examples/export-cli.rs
+++ b/crates/export/examples/export-cli.rs
@@ -55,6 +55,7 @@ async fn main() {
settings
.export(base, move |progress| {
print!("Exporting frame {progress} of {total_frames}\r");
+ true
})
.await
.unwrap();
@@ -65,6 +66,7 @@ async fn main() {
settings
.export(base, move |progress| {
print!("Exporting frame {progress} of {total_frames}\r");
+ true
})
.await
.unwrap();
diff --git a/crates/export/tests/export_benchmark.rs b/crates/export/tests/export_benchmark.rs
index 4dba40e39..873c54764 100644
--- a/crates/export/tests/export_benchmark.rs
+++ b/crates/export/tests/export_benchmark.rs
@@ -33,7 +33,8 @@ async fn run_export(project_path: PathBuf) -> Result<(PathBuf, Duration, u32), S
let output_path = settings
.export(exporter_base, move |frame| {
- frame_counter.store(frame, Ordering::Relaxed)
+ frame_counter.store(frame, Ordering::Relaxed);
+ true
})
.await
.map_err(|err| format!("Exporter error: {err}"))?;
diff --git a/crates/frame-converter/examples/benchmark.rs b/crates/frame-converter/examples/benchmark.rs
index c65c783c1..04ef56663 100644
--- a/crates/frame-converter/examples/benchmark.rs
+++ b/crates/frame-converter/examples/benchmark.rs
@@ -3,8 +3,6 @@ use cap_frame_converter::{
SwscaleConverter,
};
use ffmpeg::format::Pixel;
-use std::sync::Arc;
-use std::sync::atomic::{AtomicU64, Ordering};
use std::time::{Duration, Instant};
fn create_test_frame(format: Pixel, width: u32, height: u32) -> ffmpeg::frame::Video {
@@ -25,14 +23,14 @@ fn benchmark_single_threaded(iterations: u32, config: &ConversionConfig) -> Dura
let mut total_time = Duration::ZERO;
let mut first_frame = true;
- for i in 0..iterations {
+ for _ in 0..iterations {
let frame = create_test_frame(config.input_format, config.input_width, config.input_height);
let start = Instant::now();
let _output = converter.convert(frame).expect("Conversion failed");
let elapsed = start.elapsed();
if first_frame {
- println!(" First frame: {:?}", elapsed);
+ println!(" First frame: {elapsed:?}");
first_frame = false;
}
total_time += elapsed;
@@ -74,7 +72,7 @@ fn benchmark_pool(
}
let stats = pool.stats();
if stats.frames_converted >= frame_count as u64 {
- while let Some(_) = pool.try_recv() {
+ while pool.try_recv().is_some() {
received += 1;
}
break;
@@ -108,16 +106,16 @@ fn main() {
let warmup_iterations = 10;
let test_iterations = 100;
- println!("Warmup ({} frames)...", warmup_iterations);
+ println!("Warmup ({warmup_iterations} frames)...");
let _ = benchmark_single_threaded(warmup_iterations, &config);
- println!("Benchmark ({} frames)...", test_iterations);
+ println!("Benchmark ({test_iterations} frames)...");
let single_time = benchmark_single_threaded(test_iterations, &config);
let avg_per_frame = single_time / test_iterations;
let max_fps = 1.0 / avg_per_frame.as_secs_f64();
- println!(" Total time: {:?}", single_time);
- println!(" Avg per frame: {:?}", avg_per_frame);
- println!(" Max theoretical FPS: {:.1}", max_fps);
+ println!(" Total time: {single_time:?}");
+ println!(" Avg per frame: {avg_per_frame:?}");
+ println!(" Max theoretical FPS: {max_fps:.1}");
println!(
" Can sustain 30fps: {}",
if max_fps >= 30.0 { "YES" } else { "NO" }
@@ -127,16 +125,13 @@ fn main() {
let frame_count = 300;
for worker_count in [1, 2, 4, 6, 8] {
- println!(
- "--- Pool with {} workers ({} frames) ---",
- worker_count, frame_count
- );
+ println!("--- Pool with {worker_count} workers ({frame_count} frames) ---");
let (elapsed, converted, dropped) = benchmark_pool(frame_count, &config, worker_count);
let conversion_fps = converted as f64 / elapsed.as_secs_f64();
- println!(" Total time: {:?}", elapsed);
- println!(" Converted: {}, Dropped: {}", converted, dropped);
- println!(" Throughput: {:.1} fps", conversion_fps);
+ println!(" Total time: {elapsed:?}");
+ println!(" Converted: {converted}, Dropped: {dropped}");
+ println!(" Throughput: {conversion_fps:.1} fps");
println!(
" Can sustain 30fps: {}",
if conversion_fps >= 30.0 { "YES" } else { "NO" }
@@ -159,14 +154,14 @@ fn main() {
let time = benchmark_single_threaded(50, &alt_config);
let avg = time / 50;
let fps = 1.0 / avg.as_secs_f64();
- println!(" {}: {:.1} fps ({:?}/frame)", name, fps, avg);
+ println!(" {name}: {fps:.1} fps ({avg:?}/frame)");
}
}
println!("\n--- Real-time Simulations ---");
for encode_time_ms in [0.1, 1.0, 5.0, 10.0, 20.0] {
- println!("\n Encode time: {}ms", encode_time_ms);
+ println!("\n Encode time: {encode_time_ms}ms");
simulate_realtime_pipeline(
&config,
30.0,
@@ -203,10 +198,7 @@ fn simulate_realtime_pipeline(
let mut converted = 0u64;
let mut encode_time_total = Duration::ZERO;
- println!(
- " Simulating {} frames at {:.1} fps over {:?}",
- total_frames, target_fps, duration
- );
+ println!(" Simulating {total_frames} frames at {target_fps:.1} fps over {duration:?}");
for i in 0..total_frames {
let now = Instant::now();
@@ -233,7 +225,7 @@ fn simulate_realtime_pipeline(
let drain_deadline = Instant::now() + Duration::from_secs(5);
while Instant::now() < drain_deadline {
- if let Some(_) = pool.recv_timeout(Duration::from_millis(100)) {
+ if pool.recv_timeout(Duration::from_millis(100)).is_some() {
converted += 1;
} else {
break;
@@ -243,16 +235,14 @@ fn simulate_realtime_pipeline(
let elapsed = start.elapsed();
let stats = pool.stats();
- println!(" Elapsed: {:?}", elapsed);
- println!(
- " Submitted: {}, Converted: {}, Dropped: {}",
- submitted, converted, stats.frames_dropped
- );
+ println!(" Elapsed: {elapsed:?}");
println!(
- " Drop rate: {:.1}%",
- (stats.frames_dropped as f64 / total_frames as f64) * 100.0
+ " Submitted: {submitted}, Converted: {converted}, Dropped: {}",
+ stats.frames_dropped
);
- println!(" Total encode time: {:?}", encode_time_total);
+ let drop_rate = (stats.frames_dropped as f64 / total_frames as f64) * 100.0;
+ println!(" Drop rate: {drop_rate:.1}%");
+ println!(" Total encode time: {encode_time_total:?}");
let expected_duration = Duration::from_secs_f64(total_frames as f64 / target_fps);
let overhead = if elapsed > expected_duration {
@@ -260,7 +250,7 @@ fn simulate_realtime_pipeline(
} else {
Duration::ZERO
};
- println!(" Processing overhead: {:?}", overhead);
+ println!(" Processing overhead: {overhead:?}");
if stats.frames_dropped == 0 {
println!(" Result: SUCCESS - No frames dropped!");
diff --git a/crates/frame-converter/src/lib.rs b/crates/frame-converter/src/lib.rs
index ed3664692..21094440e 100644
--- a/crates/frame-converter/src/lib.rs
+++ b/crates/frame-converter/src/lib.rs
@@ -188,8 +188,8 @@ pub fn create_converter_with_details(
});
}
Err(e) => {
- let reason = format!("VideoToolbox: {}", e);
- tracing::debug!("{}", reason);
+ let reason = format!("VideoToolbox: {e}");
+ tracing::debug!("{reason}");
fallback_reasons.push(reason);
}
}
@@ -212,8 +212,8 @@ pub fn create_converter_with_details(
});
}
Err(e) => {
- let reason = format!("D3D11: {}", e);
- tracing::debug!("{}", reason);
+ let reason = format!("D3D11: {e}");
+ tracing::debug!("{reason}");
fallback_reasons.push(reason);
}
}
diff --git a/crates/frame-converter/src/pool.rs b/crates/frame-converter/src/pool.rs
index a4ebdcb5b..e90defc68 100644
--- a/crates/frame-converter/src/pool.rs
+++ b/crates/frame-converter/src/pool.rs
@@ -130,7 +130,7 @@ impl AsyncConverterPool {
let drop_strategy = config.drop_strategy;
let handle = thread::Builder::new()
- .name(format!("converter-worker-{}", worker_id))
+ .name(format!("converter-worker-{worker_id}"))
.spawn(move || {
let converter = match factory(worker_id) {
Ok(c) => c,
diff --git a/crates/frame-converter/src/videotoolbox.rs b/crates/frame-converter/src/videotoolbox.rs
index 560059e0d..78fa04c5c 100644
--- a/crates/frame-converter/src/videotoolbox.rs
+++ b/crates/frame-converter/src/videotoolbox.rs
@@ -99,21 +99,20 @@ pub struct VideoToolboxConverter {
impl VideoToolboxConverter {
pub fn new(config: ConversionConfig) -> Result<Self, ConvertError> {
- let input_cv_format = pixel_to_cv_format(config.input_format).ok_or_else(|| {
- ConvertError::UnsupportedFormat(config.input_format, config.output_format)
- })?;
+ let input_cv_format = pixel_to_cv_format(config.input_format).ok_or(
+ ConvertError::UnsupportedFormat(config.input_format, config.output_format),
+ )?;
- let output_cv_format = pixel_to_cv_format(config.output_format).ok_or_else(|| {
- ConvertError::UnsupportedFormat(config.input_format, config.output_format)
- })?;
+ let output_cv_format = pixel_to_cv_format(config.output_format).ok_or(
+ ConvertError::UnsupportedFormat(config.input_format, config.output_format),
+ )?;
let mut session: VTPixelTransferSessionRef = ptr::null_mut();
let status = unsafe { VTPixelTransferSessionCreate(ptr::null(), &mut session) };
if status != 0 {
return Err(ConvertError::HardwareUnavailable(format!(
- "VTPixelTransferSessionCreate failed with status: {}",
- status
+ "VTPixelTransferSessionCreate failed with status: {status}"
)));
}
@@ -174,8 +173,7 @@ impl VideoToolboxConverter {
if status != K_CV_RETURN_SUCCESS {
return Err(ConvertError::ConversionFailed(format!(
- "CVPixelBufferCreateWithBytes failed: {}",
- status
+ "CVPixelBufferCreateWithBytes failed: {status}"
)));
}
@@ -198,8 +196,7 @@ impl VideoToolboxConverter {
if status != K_CV_RETURN_SUCCESS {
return Err(ConvertError::ConversionFailed(format!(
- "CVPixelBufferCreate failed: {}",
- status
+ "CVPixelBufferCreate failed: {status}"
)));
}
@@ -214,8 +211,7 @@ impl VideoToolboxConverter {
let lock_status = CVPixelBufferLockBaseAddress(pixel_buffer, 0);
if lock_status != K_CV_RETURN_SUCCESS {
return Err(ConvertError::ConversionFailed(format!(
- "CVPixelBufferLockBaseAddress failed: {}",
- lock_status
+ "CVPixelBufferLockBaseAddress failed: {lock_status}"
)));
}
}
@@ -289,8 +285,7 @@ impl FrameConverter for VideoToolboxConverter {
CVPixelBufferRelease(output_buffer);
}
return Err(ConvertError::ConversionFailed(format!(
- "VTPixelTransferSessionTransferImage failed: {}",
- status
+ "VTPixelTransferSessionTransferImage failed: {status}"
)));
}
diff --git a/crates/project/src/configuration.rs b/crates/project/src/configuration.rs
index ad73c3bc9..449fe30f9 100644
--- a/crates/project/src/configuration.rs
+++ b/crates/project/src/configuration.rs
@@ -917,8 +917,7 @@ impl fmt::Display for AnnotationValidationError {
annotation_type,
} => write!(
f,
- "annotation {id} with type {:?} cannot include mask data",
- annotation_type
+ "annotation {id} with type {annotation_type:?} cannot include mask data"
),
}
}
diff --git a/crates/recording/src/benchmark.rs b/crates/recording/src/benchmark.rs
index 411c9d6d7..6da4a285e 100644
--- a/crates/recording/src/benchmark.rs
+++ b/crates/recording/src/benchmark.rs
@@ -263,53 +263,53 @@ impl MetricsSnapshot {
println!("\n--- Conversion Timing ---");
if let Some(avg) = self.avg_conversion_time() {
- println!(" Average: {:?}", avg);
+ println!(" Average: {avg:?}");
}
if let Some(p50) = self.percentile_conversion_time(50.0) {
- println!(" P50: {:?}", p50);
+ println!(" P50: {p50:?}");
}
if let Some(p95) = self.percentile_conversion_time(95.0) {
- println!(" P95: {:?}", p95);
+ println!(" P95: {p95:?}");
}
if let Some(p99) = self.percentile_conversion_time(99.0) {
- println!(" P99: {:?}", p99);
+ println!(" P99: {p99:?}");
}
if let Some(max) = self.max_conversion_time() {
- println!(" Max: {:?}", max);
+ println!(" Max: {max:?}");
}
println!("\n--- Encoding Timing ---");
if let Some(avg) = self.avg_encode_time() {
- println!(" Average: {:?}", avg);
+ println!(" Average: {avg:?}");
}
if let Some(p50) = self.percentile_encode_time(50.0) {
- println!(" P50: {:?}", p50);
+ println!(" P50: {p50:?}");
}
if let Some(p95) = self.percentile_encode_time(95.0) {
- println!(" P95: {:?}", p95);
+ println!(" P95: {p95:?}");
}
if let Some(p99) = self.percentile_encode_time(99.0) {
- println!(" P99: {:?}", p99);
+ println!(" P99: {p99:?}");
}
if let Some(max) = self.max_encode_time() {
- println!(" Max: {:?}", max);
+ println!(" Max: {max:?}");
}
println!("\n--- Total Pipeline Latency ---");
if let Some(avg) = self.avg_pipeline_latency() {
- println!(" Average: {:?}", avg);
+ println!(" Average: {avg:?}");
}
if let Some(p50) = self.percentile_pipeline_latency(50.0) {
- println!(" P50: {:?}", p50);
+ println!(" P50: {p50:?}");
}
if let Some(p95) = self.percentile_pipeline_latency(95.0) {
- println!(" P95: {:?}", p95);
+ println!(" P95: {p95:?}");
}
if let Some(p99) = self.percentile_pipeline_latency(99.0) {
- println!(" P99: {:?}", p99);
+ println!(" P99: {p99:?}");
}
if let Some(max) = self.max_pipeline_latency() {
- println!(" Max: {:?}", max);
+ println!(" Max: {max:?}");
}
println!("\n--- Performance Assessment ---");
@@ -455,7 +455,7 @@ impl EncoderInfo {
pub fn print_info(&self) {
println!("Encoder: {} (Hardware: {})", self.name, self.is_hardware);
if let Some(gpu) = &self.gpu_type {
- println!("GPU: {}", gpu);
+ println!("GPU: {gpu}");
}
}
}
diff --git a/crates/recording/src/output_pipeline/async_camera.rs b/crates/recording/src/output_pipeline/async_camera.rs
index c62021f87..dca0c510a 100644
--- a/crates/recording/src/output_pipeline/async_camera.rs
+++ b/crates/recording/src/output_pipeline/async_camera.rs
@@ -152,7 +152,7 @@ impl Muxer for AsyncCameraMp4Muxer {
pool.drain_with_timeout(
|converted| {
let pts = converted.frame.pts().unwrap_or(0);
- if last_pts.map_or(true, |last| pts > last) {
+ if last_pts.is_none_or(|last| pts > last) {
let timestamp = Duration::from_micros(pts as u64);
if let Err(e) = encoder_ref.queue_preconverted_frame(
converted.frame,
@@ -236,7 +236,7 @@ impl VideoMuxer for AsyncCameraMp4Muxer {
let mut encoded_this_call = 0u64;
while let Some(converted) = pool.try_recv() {
let pts = converted.frame.pts().unwrap_or(0);
- if self.last_pts.map_or(true, |last| pts > last) {
+ if self.last_pts.is_none_or(|last| pts > last) {
let frame_timestamp = Duration::from_micros(pts as u64);
encoder.queue_preconverted_frame(
converted.frame,
@@ -253,7 +253,7 @@ impl VideoMuxer for AsyncCameraMp4Muxer {
if encoded_this_call == 0 && backlog > 10 {
if let Some(converted) = pool.recv_timeout(Duration::from_millis(5)) {
let pts = converted.frame.pts().unwrap_or(0);
- if self.last_pts.map_or(true, |last| pts > last) {
+ if self.last_pts.is_none_or(|last| pts > last) {
let frame_timestamp = Duration::from_micros(pts as u64);
encoder.queue_preconverted_frame(
converted.frame,
diff --git a/crates/rendering-skia/src/layers/background.rs b/crates/rendering-skia/src/layers/background.rs
index a6318fbe7..bd603ca1d 100644
--- a/crates/rendering-skia/src/layers/background.rs
+++ b/crates/rendering-skia/src/layers/background.rs
@@ -334,6 +334,7 @@ mod tests {
// Test color conversion
let color_source = BackgroundSource::Color {
value: [65535, 32768, 0],
+ alpha: 255,
};
let color_bg = Background::from(color_source);
assert!(matches!(color_bg, Background::Color([65535, 32768, 0])));
@@ -358,6 +359,7 @@ mod tests {
output_size: (800, 600),
background: BackgroundSource::Color {
value: [65535, 0, 0],
+ alpha: 255,
},
border: None,
};
@@ -382,6 +384,7 @@ mod tests {
output_size: (800, 600),
background: BackgroundSource::Color {
value: [0, 65535, 0],
+ alpha: 255,
},
border: None,
};
diff --git a/crates/rendering/src/layers/captions.rs b/crates/rendering/src/layers/captions.rs
index 98a99b7da..667b1a3f3 100644
--- a/crates/rendering/src/layers/captions.rs
+++ b/crates/rendering/src/layers/captions.rs
@@ -19,7 +19,7 @@ pub struct CaptionWord {
#[derive(Debug, Clone)]
pub struct CaptionSegment {
- pub id: String,
+ pub _id: String,
pub start: f32,
pub end: f32,
pub text: String,
@@ -95,7 +95,7 @@ impl CaptionPosition {
}
}
- fn x_alignment(&self) -> f32 {
+ fn _x_alignment(&self) -> f32 {
match self {
Self::TopLeft | Self::BottomLeft => 0.05,
Self::TopCenter | Self::BottomCenter => 0.5,
@@ -234,7 +234,7 @@ fn calculate_word_highlight(
}
pub struct CaptionsLayer {
- settings_buffer: wgpu::Buffer,
+ _settings_buffer: wgpu::Buffer,
font_system: FontSystem,
swash_cache: SwashCache,
text_atlas: TextAtlas,
@@ -356,7 +356,7 @@ impl CaptionsLayer {
});
Self {
- settings_buffer,
+ _settings_buffer: settings_buffer,
font_system,
swash_cache,
text_atlas,
@@ -375,8 +375,9 @@ impl CaptionsLayer {
}
}
+ #[allow(dead_code)]
pub fn update_settings(&mut self, queue: &Queue, settings: CaptionSettings) {
- queue.write_buffer(&self.settings_buffer, 0, bytemuck::cast_slice(&[settings]));
+ queue.write_buffer(&self._settings_buffer, 0, bytemuck::cast_slice(&[settings]));
}
pub fn update_caption(&mut self, text: Option<String>, start: f32, end: f32) {
@@ -850,6 +851,7 @@ impl CaptionsLayer {
}
}
+#[allow(dead_code)]
pub fn find_caption_at_time(time: f32, segments: &[CaptionSegment]) -> Option<&CaptionSegment> {
segments
.iter()
@@ -866,7 +868,7 @@ const CLOSE_TRANSITION_THRESHOLD: f32 = 0.4;
fn convert_project_segment(segment: &cap_project::CaptionSegment) -> CaptionSegment {
CaptionSegment {
- id: segment.id.clone(),
+ _id: segment.id.clone(),
start: segment.start,
end: segment.end,
text: segment.text.clone(),
diff --git a/crates/rendering/src/layers/text.rs b/crates/rendering/src/layers/text.rs
index aac7b846a..5891efbe0 100644
--- a/crates/rendering/src/layers/text.rs
+++ b/crates/rendering/src/layers/text.rs
@@ -77,7 +77,7 @@ impl TextLayer {
}
"serif" | "system serif" => Family::Serif,
"mono" | "monospace" | "system mono" | "system monospace" => Family::Monospace,
- _ => Family::Name(name.into()),
+ _ => Family::Name(name),
},
};
let weight = Weight(text.font_weight.round().clamp(100.0, 900.0) as u16);
@@ -118,7 +118,7 @@ impl TextLayer {
let text_areas = self
.buffers
.iter()
- .zip(text_area_data.into_iter())
+ .zip(text_area_data)
.map(|(buffer, (bounds, left, top, color))| TextArea {
buffer,
left,