feat: 完善Topaz Video AI SDK并重新组织models目录结构

主要改进:
 AI引擎和基准测试支持:
- 完整支持所有AI引擎标志 (Artemis, Gaia, Theia, Proteus, Iris)
- 实现引擎特定的参数优化和FFmpeg命令生成
- 添加基准测试模板和性能测试功能
- 新增专用预设模板 (animation_enhance, detail_recovery等)

 音频编码器智能化:
- 完善音频编码器配置和自动选择
- 支持AAC, AC3, PCM, Vorbis等多种编码器
- 实现质量级别自动映射和容器格式兼容性检查
- 添加音频编码器演示示例

 目录结构重新组织:
- 将models目录按功能分类重新组织
- 视觉-语言模型配置 -> 视觉-语言模型配置/
- 编码解码配置 -> 编码解码配置/
- 基准测试配置 -> config/
- 其他配置文件 -> 其他配置/

 技术增强:
- 增强TemplateBuilder功能 (ai_engine, focus_fix_level, benchmark_mode等)
- 完善FFmpeg参数生成和模型映射
- 添加智能推荐系统和性能优化
- 新增多个演示示例 (benchmarks_demo, audio_codecs_demo等)

 完整性提升:
- 模板属性使用率达到100%
- 所有AI引擎和编码器都有明确用途和处理方案
- 完整的文档分析和使用指南
This commit is contained in:
imeepos
2025-08-15 15:04:56 +08:00
parent bf880a55a6
commit 5380d9973f
164 changed files with 698 additions and 62 deletions

View File

@@ -33,18 +33,37 @@ impl FfmpegCommandGenerator {
// Artemis series (animation/cartoon)
self.model_mappings.insert("art-1".to_string(), "art-1".to_string());
self.model_mappings.insert("art-2".to_string(), "art-2".to_string());
self.model_mappings.insert("alq-13".to_string(), "ahq-12".to_string()); // Artemis benchmark model
// Gaia series (natural scenes)
self.model_mappings.insert("gai-1".to_string(), "gai-1".to_string());
self.model_mappings.insert("gai-2".to_string(), "gai-2".to_string());
self.model_mappings.insert("ghq-5".to_string(), "ahq-12".to_string()); // Gaia benchmark model
// Theia series (detail recovery)
self.model_mappings.insert("the-1".to_string(), "the-1".to_string());
self.model_mappings.insert("the-2".to_string(), "the-2".to_string());
// Iris series (low light/noise)
self.model_mappings.insert("iris-1".to_string(), "nyx-3".to_string());
self.model_mappings.insert("iris-2".to_string(), "nyx-3".to_string());
self.model_mappings.insert("iris-3".to_string(), "nyx-3".to_string()); // Iris benchmark model
// Nyx series (noise reduction)
self.model_mappings.insert("nyx-1".to_string(), "nyx-3".to_string());
self.model_mappings.insert("nyx-2".to_string(), "nyx-3".to_string()); // Nyx benchmark model
self.model_mappings.insert("nxf-1".to_string(), "nyx-3".to_string()); // Nyx Fast benchmark model
// Specialized models
self.model_mappings.insert("rhea-1".to_string(), "ahq-12".to_string()); // Rhea benchmark model
self.model_mappings.insert("rxl-1".to_string(), "ahq-12".to_string()); // RXL benchmark model
// Frame interpolation models
self.model_mappings.insert("apo-8".to_string(), "chr-2".to_string());
self.model_mappings.insert("chf-3".to_string(), "chr-2".to_string());
self.model_mappings.insert("apo-8".to_string(), "chr-2".to_string()); // Apollo
self.model_mappings.insert("apf-1".to_string(), "chr-2".to_string()); // Apollo Fast
self.model_mappings.insert("chr-2".to_string(), "chr-2".to_string()); // Chronos
self.model_mappings.insert("chf-3".to_string(), "chr-2".to_string()); // Chronos Fast
self.model_mappings.insert("aion-1".to_string(), "chr-2".to_string()); // Aion (16X)
// Motion blur models
self.model_mappings.insert("thm-2".to_string(), "thm-2".to_string());

View File

@@ -290,6 +290,64 @@ impl TemplateBuilder {
self
}
/// Set audio settings with automatic optimization
pub fn audio_settings_optimized(mut self, codec: &str, quality: &str) -> Self {
self.template.settings.output.audio_codec = Some(codec.to_string());
// Set optimized bitrate based on codec and quality
let bitrate = match (codec.to_lowercase().as_str(), quality.to_lowercase().as_str()) {
("aac", "low") => 128,
("aac", "medium") => 192,
("aac", "high") => 256,
("aac", "highest") => 320,
("ac3", "low") => 160,
("ac3", "medium") => 256,
("ac3", "high") => 448,
("ac3", "highest") => 640,
("pcm", _) => 0, // Lossless, no bitrate needed
("vorbis", _) => 192, // Default for Vorbis
_ => 192, // Safe default
};
if bitrate > 0 {
self.template.settings.output.audio_bitrate = Some(bitrate);
}
// Set appropriate channels based on codec
let channels = match codec.to_lowercase().as_str() {
"aac" | "vorbis" => 2, // Stereo
"ac3" => 6, // 5.1 surround
"pcm" => 2, // Stereo for PCM
_ => 2, // Default stereo
};
self.template.settings.output.audio_channels = Some(channels);
self
}
/// Set container format with compatible audio codec
pub fn container_format(mut self, format: &str) -> Self {
self.template.settings.output.format = Some(format.to_string());
// Auto-select compatible audio codec if not set
if self.template.settings.output.audio_codec.is_none() {
let codec = match format.to_lowercase().as_str() {
"mp4" | "mov" | "mkv" | "avi" => "aac", // AAC is widely compatible
"webm" => "vorbis", // Vorbis for WebM
_ => "aac", // Default to AAC
};
self.template.settings.output.audio_codec = Some(codec.to_string());
// Set appropriate channels and bitrate for the codec
if codec == "vorbis" {
self.template.settings.output.audio_channels = Some(2);
self.template.settings.output.audio_bitrate = Some(192);
}
}
self
}
/// Set hardware acceleration
pub fn hardware_acceleration(mut self, hwaccel: &str, device: Option<&str>) -> Self {
self.template.settings.output.hwaccel = Some(hwaccel.to_string());
@@ -403,6 +461,48 @@ impl TemplateBuilder {
self
}
/// Set benchmark mode (disables all non-essential processing)
pub fn benchmark_mode(mut self, enabled: bool) -> Self {
if enabled {
// Disable all non-essential processing for pure model benchmarking
self.template.settings.stabilize.active = false;
self.template.settings.grain.active = false;
self.template.settings.motion_blur.active = false;
// Use minimal output settings
self.template.settings.output.active = false;
// Clear audio settings for video-only benchmarking
self.template.settings.output.audio_codec = None;
self.template.settings.output.audio_bitrate = None;
self.template.settings.output.audio_channels = None;
}
self
}
/// Create a benchmark template for specific AI engine and scale
pub fn benchmark_template(engine: &str, scale: i32) -> Result<Template, TvaiError> {
let (model, description) = match engine.to_lowercase().as_str() {
"artemis" => ("alq-13", "Artemis animation optimization benchmark"),
"iris" => ("iris-3", "Iris low-light processing benchmark"),
"proteus" => ("prob-4", "Proteus general enhancement benchmark"),
"gaia" => ("ghq-5", "Gaia natural scene benchmark"),
"nyx" => ("nyx-2", "Nyx noise reduction benchmark"),
"nyx_fast" => ("nxf-1", "Nyx Fast noise reduction benchmark"),
"rhea" => ("rhea-1", "Rhea specialized enhancement benchmark"),
"rxl" => ("rxl-1", "RXL ultra-high quality benchmark"),
"hyperion" => ("hyp-1", "Hyperion HDR processing benchmark"),
_ => return Err(TvaiError::ValidationError(format!("Unknown benchmark engine: {}", engine))),
};
TemplateBuilder::new(&format!("Benchmark {} {}X", engine, scale))
.description(description)
.enable_enhancement(model)
.enhancement_params(0, 0, 0) // No additional processing
.benchmark_mode(true) // Enable benchmark mode
.build()
}
/// Enable grain effect
pub fn enable_grain(mut self, amount: i32, size: i32) -> Self {
self.template.settings.grain.active = true;
@@ -656,6 +756,81 @@ impl TemplatePresets {
.resolution(1920, 1080)
.build()
}
/// Create a web-optimized template
pub fn web_optimized() -> Result<Template, TvaiError> {
TemplateBuilder::new("Web Optimized")
.description("Optimized for web streaming with WebM container")
.enable_enhancement("prob-4")
.enhancement_params(15, 20, 10) // Light processing for web
.resolution(1920, 1080)
.video_codec("libvpx-vp9", Some(30)) // VP9 for WebM
.container_format("webm") // Auto-selects Vorbis audio
.audio_settings_optimized("vorbis", "medium")
.preset("fast")
.build()
}
/// Create a professional master template
pub fn professional_master() -> Result<Template, TvaiError> {
TemplateBuilder::new("Professional Master")
.description("Professional quality with lossless audio")
.enable_enhancement("prob-4")
.enhancement_params(30, 40, 20) // High quality settings
.resolution(3840, 2160) // 4K
.video_codec("libx265", Some(15)) // High quality H.265
.container_format("mov") // Professional container
.audio_settings_optimized("pcm", "highest") // Lossless audio
.preset("veryslow")
.build()
}
/// Create a broadcast template
pub fn broadcast_ready() -> Result<Template, TvaiError> {
TemplateBuilder::new("Broadcast Ready")
.description("Broadcast standard with AC3 surround sound")
.enable_enhancement("prob-4")
.enhancement_params(20, 25, 15) // Broadcast quality
.resolution(1920, 1080)
.video_codec("libx264", Some(18)) // Broadcast quality
.container_format("mp4")
.audio_settings_optimized("ac3", "high") // 5.1 surround
.preset("medium")
.build()
}
/// Create benchmark templates for performance testing
pub fn benchmark_artemis_2x() -> Result<Template, TvaiError> {
TemplateBuilder::new("Benchmark Artemis 2X")
.description("Artemis 2X upscaling benchmark")
.enable_enhancement("alq-13")
.enhancement_params(0, 0, 0) // Pure model performance
.build()
}
pub fn benchmark_proteus_4x() -> Result<Template, TvaiError> {
TemplateBuilder::new("Benchmark Proteus 4X")
.description("Proteus 4X upscaling benchmark")
.enable_enhancement("prob-4")
.enhancement_params(0, 0, 0) // Pure model performance
.build()
}
pub fn benchmark_apollo_slowmo() -> Result<Template, TvaiError> {
TemplateBuilder::new("Benchmark Apollo 4X Slowmo")
.description("Apollo 4X slow motion benchmark")
.enable_enhancement("prob-4")
.enable_frame_interpolation("apo-8", 4.0) // 4X slow motion
.build()
}
pub fn benchmark_hyperion_hdr() -> Result<Template, TvaiError> {
TemplateBuilder::new("Benchmark Hyperion HDR")
.description("Hyperion HDR processing benchmark")
.enable_enhancement("hyp-1")
.enhancement_params(0, 0, 0) // Pure HDR processing
.build()
}
}
impl Default for TvaiSdk {