From 49f4b27a461826b223139255df80a428de6431da Mon Sep 17 00:00:00 2001 From: imeepos Date: Wed, 13 Aug 2025 14:28:34 +0800 Subject: [PATCH] fix: build error --- Cargo.lock | 1 + cargos/tvai/Cargo.toml | 1 + cargos/tvai/src/filters/combinations.rs | 4 ++-- cargos/tvai/src/filters/mod.rs | 6 +++--- cargos/tvai/src/filters/presets.rs | 2 +- cargos/tvai/src/utils/model_manager.rs | 7 +++---- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 451f561..2d51907 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5679,6 +5679,7 @@ dependencies = [ "criterion", "dirs 5.0.1", "serde", + "serde_json", "tempfile", "thiserror 1.0.69", "tokio", diff --git a/cargos/tvai/Cargo.toml b/cargos/tvai/Cargo.toml index 26aeb34..4fe0446 100644 --- a/cargos/tvai/Cargo.toml +++ b/cargos/tvai/Cargo.toml @@ -13,6 +13,7 @@ categories = ["multimedia::video", "multimedia::images"] tokio = { version = "1.0", features = ["full"] } anyhow = "1.0" serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" uuid = { version = "1.0", features = ["v4"] } tempfile = "3.0" async-trait = "0.1" diff --git a/cargos/tvai/src/filters/combinations.rs b/cargos/tvai/src/filters/combinations.rs index c024bf3..68d86d3 100644 --- a/cargos/tvai/src/filters/combinations.rs +++ b/cargos/tvai/src/filters/combinations.rs @@ -237,7 +237,7 @@ impl FilterProcessor { } // 执行 CPE - let mut cpe_cmd = vec![ + let cpe_cmd = vec![ "-y", "-hide_banner", "-nostdin", "-i", input_path.to_str().unwrap(), "-filter_complex", &cpe_filter, @@ -313,7 +313,7 @@ impl FilterProcessor { } /// 添加编码参数 - fn add_encoding_args(&self, args: &mut Vec<&str>, quality: &QualityLevel, options: &ProcessOptions) { + fn add_encoding_args(&self, args: &mut Vec<&str>, quality: &QualityLevel, _options: &ProcessOptions) { // 根据质量等级选择编码参数 match quality { QualityLevel::Fast => { diff --git a/cargos/tvai/src/filters/mod.rs b/cargos/tvai/src/filters/mod.rs index 241d92d..a8265e9 100644 --- a/cargos/tvai/src/filters/mod.rs +++ b/cargos/tvai/src/filters/mod.rs @@ -11,7 +11,7 @@ use crate::core::{TvaiError, TvaiProcessor, ProcessResult, ProgressCallback}; use crate::config::UpscaleModel; /// 滤镜组合类型 -#[derive(Debug, Clone)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub enum FilterCombination { /// 超分辨率放大 Upscale { @@ -50,7 +50,7 @@ pub enum FilterCombination { } /// 质量等级 -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)] pub enum QualityLevel { /// 快速处理 Fast, @@ -63,7 +63,7 @@ pub enum QualityLevel { } /// 处理选项 -#[derive(Debug, Clone)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct ProcessOptions { /// 输出格式 (mp4, mov, avi 等) pub output_format: Option, diff --git a/cargos/tvai/src/filters/presets.rs b/cargos/tvai/src/filters/presets.rs index ea973ac..731a154 100644 --- a/cargos/tvai/src/filters/presets.rs +++ b/cargos/tvai/src/filters/presets.rs @@ -222,7 +222,7 @@ impl PresetBuilder { } /// 自定义预设 -#[derive(Debug, Clone)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct CustomPreset { pub name: String, pub description: String, diff --git a/cargos/tvai/src/utils/model_manager.rs b/cargos/tvai/src/utils/model_manager.rs index c794d9d..86b9ed0 100644 --- a/cargos/tvai/src/utils/model_manager.rs +++ b/cargos/tvai/src/utils/model_manager.rs @@ -231,8 +231,7 @@ impl ModelManager { guide.push_str(&format!("```\n\"{}\"\n```\n", topaz_exe.display())); } - fs::write(output_path, guide) - .map_err(|e| TvaiError::IoError(format!("Failed to write guide: {}", e)))?; + fs::write(output_path, guide)?; Ok(()) } @@ -242,7 +241,7 @@ impl ModelManager { if let Some(topaz_exe) = &self.topaz_exe { Command::new(topaz_exe) .spawn() - .map_err(|e| TvaiError::ProcessError(format!("Failed to launch Topaz: {}", e)))?; + .map_err(|e| TvaiError::ProcessingError(format!("Failed to launch Topaz: {}", e)))?; Ok(()) } else { Err(TvaiError::TopazNotFound("Topaz Video AI executable not found".to_string())) @@ -274,7 +273,7 @@ impl ModelManager { let output = Command::new(&self.topaz_ffmpeg) .args(&args) .output() - .map_err(|e| TvaiError::ProcessError(format!("Failed to execute FFmpeg: {}", e)))?; + .map_err(|e| TvaiError::ProcessingError(format!("Failed to execute FFmpeg: {}", e)))?; // 清理临时文件 let _ = fs::remove_file(&output_file);