mixvideo-v2/cargos/tvai-v2/examples/benchmarks_demo.rs

176 lines
8.0 KiB
Rust

use tvai_sdk::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Topaz Video AI SDK - Benchmarks Demo");
println!("===================================");
let sdk = TvaiSdk::new();
// Example 1: Image Enhancement Benchmarks
println!("\n1. Image Enhancement Benchmarks:");
let enhancement_engines = vec![
("Artemis", "alq-13", "Animation/Cartoon optimization"),
("Iris", "iris-3", "Low-light/Noise processing"),
("Proteus", "prob-4", "General purpose enhancement"),
("Gaia", "ghq-5", "Natural scene optimization"),
("Nyx", "nyx-2", "Noise reduction specialist"),
];
for (engine, model, description) in enhancement_engines {
println!("\n {} Engine ({}):", engine, description);
// Test different scales
let scales = if engine == "Nyx" { vec![1, 2] } else { vec![1, 2, 4] };
for scale in scales {
let template = TemplateBuilder::benchmark_template(engine, scale)?;
let command = sdk.generate_ffmpeg_command(&template, "input.mp4", &format!("benchmark_{}_{}.mp4", engine.to_lowercase(), scale))?;
println!(" {}X Scale: {}", scale, command);
}
}
// Example 2: Specialized Enhancement Benchmarks
println!("\n2. Specialized Enhancement Benchmarks:");
// Rhea - 4X only
let rhea_template = TemplateBuilder::benchmark_template("rhea", 4)?;
let rhea_command = sdk.generate_ffmpeg_command(&rhea_template, "input.mp4", "benchmark_rhea_4x.mp4")?;
println!(" Rhea 4X (Specialized): {}", rhea_command);
// RXL - 4X ultra-high quality
let rxl_template = TemplateBuilder::benchmark_template("rxl", 4)?;
let rxl_command = sdk.generate_ffmpeg_command(&rxl_template, "input.mp4", "benchmark_rxl_4x.mp4")?;
println!(" RXL 4X (Ultra-HQ): {}", rxl_command);
// Hyperion HDR - 1X only
let hdr_template = TemplateBuilder::benchmark_template("hyperion", 1)?;
let hdr_command = sdk.generate_ffmpeg_command(&hdr_template, "input.mp4", "benchmark_hdr.mp4")?;
println!(" Hyperion HDR: {}", hdr_command);
// Example 3: Frame Interpolation Benchmarks
println!("\n3. Frame Interpolation Benchmarks:");
// 4X Slow Motion engines
let slowmo_4x_engines = vec![
("Apollo", "apo-8", "High quality interpolation"),
("APFast", "apf-1", "Fast interpolation"),
("Chronos", "chr-2", "Balanced quality/speed"),
("CHFast", "chf-3", "Fast interpolation"),
];
for (engine, model, description) in slowmo_4x_engines {
let template = TemplateBuilder::new(&format!("Benchmark {} 4X Slowmo", engine))
.description(&format!("{} - 4X slow motion benchmark", description))
.enable_enhancement("prob-4") // Base enhancement
.enable_frame_interpolation(model, 4.0) // 4X slow motion
.benchmark_mode(true)
.build()?;
let command = sdk.generate_ffmpeg_command(&template, "input.mp4", &format!("benchmark_slowmo_{}_{}.mp4", engine.to_lowercase(), 4))?;
println!(" {} 4X ({}): {}", engine, description, command);
}
// 16X Slow Motion - Aion only
let aion_template = TemplateBuilder::new("Benchmark Aion 16X Slowmo")
.description("Aion ultra-high slow motion benchmark")
.enable_enhancement("prob-4")
.enable_frame_interpolation("aion-1", 16.0) // 16X slow motion
.benchmark_mode(true)
.build()?;
let aion_command = sdk.generate_ffmpeg_command(&aion_template, "input.mp4", "benchmark_slowmo_aion_16x.mp4")?;
println!(" Aion 16X (Ultra-slow): {}", aion_command);
// Example 4: Performance Comparison Templates
println!("\n4. Performance Comparison Templates:");
// Compare different engines at 2X scale
println!(" 2X Upscaling Comparison:");
let comparison_engines = vec!["Artemis", "Iris", "Proteus", "Gaia"];
for engine in comparison_engines {
let template = TemplateBuilder::benchmark_template(engine, 2)?;
let command = sdk.generate_ffmpeg_command(&template, "test_input.mp4", &format!("compare_2x_{}.mp4", engine.to_lowercase()))?;
println!(" {}: {}", engine, command);
}
// Example 5: Benchmark Mode Features
println!("\n5. Benchmark Mode Features:");
let normal_template = TemplateBuilder::new("Normal Template")
.description("Normal processing template")
.enable_enhancement("prob-4")
.enhancement_params(25, 30, 20)
.enable_stabilization(60, 1)
.audio_settings("aac", 192, 2)
.build()?;
let benchmark_template = TemplateBuilder::new("Benchmark Template")
.description("Benchmark mode template")
.enable_enhancement("prob-4")
.enhancement_params(0, 0, 0) // No additional processing
.benchmark_mode(true) // Disables non-essential features
.build()?;
println!(" Normal Template Features:");
println!(" Stabilization: {}", normal_template.settings.stabilize.active);
println!(" Grain: {}", normal_template.settings.grain.active);
println!(" Audio: {}", normal_template.settings.output.audio_codec.is_some());
println!(" Benchmark Template Features:");
println!(" Stabilization: {}", benchmark_template.settings.stabilize.active);
println!(" Grain: {}", benchmark_template.settings.grain.active);
println!(" Audio: {}", benchmark_template.settings.output.audio_codec.is_some());
let normal_command = sdk.generate_ffmpeg_command(&normal_template, "input.mp4", "normal_output.mp4")?;
let benchmark_command = sdk.generate_ffmpeg_command(&benchmark_template, "input.mp4", "benchmark_output.mp4")?;
println!(" Normal Command: {}", normal_command);
println!(" Benchmark Command: {}", benchmark_command);
// Example 6: Engine Capabilities Summary
println!("\n6. Engine Capabilities Summary:");
println!(" 📊 Scaling Capabilities:");
println!(" Artemis: 1X ✅ 2X ✅ 4X ✅ (Animation optimized)");
println!(" Iris: 1X ✅ 2X ✅ 4X ✅ (Low-light optimized)");
println!(" Proteus: 1X ✅ 2X ✅ 4X ✅ (General purpose)");
println!(" Gaia: 1X ✅ 2X ✅ 4X ✅ (Natural scenes)");
println!(" Nyx: 1X ✅ 2X ✅ 4X ❌ (Noise reduction)");
println!(" Nyx Fast: 1X ✅ 2X ❌ 4X ❌ (Fast noise reduction)");
println!(" Rhea: 1X ❌ 2X ❌ 4X ✅ (Specialized 4X)");
println!(" RXL: 1X ❌ 2X ❌ 4X ✅ (Ultra-high quality 4X)");
println!(" Hyperion: 1X ✅ 2X ❌ 4X ❌ (HDR processing)");
println!("\n 🎬 Frame Interpolation:");
println!(" Apollo: 4X Slowmo ✅ (High quality)");
println!(" APFast: 4X Slowmo ✅ (Fast processing)");
println!(" Chronos: 4X Slowmo ✅ (Balanced)");
println!(" CHFast: 4X Slowmo ✅ (Fast processing)");
println!(" Aion: 16X Slowmo ✅ (Ultra-slow motion)");
println!("\n 🎯 Recommended Use Cases:");
println!(" • Animation/Cartoons: Artemis");
println!(" • Low-light footage: Iris");
println!(" • General content: Proteus");
println!(" • Nature/Landscapes: Gaia");
println!(" • Noisy footage: Nyx/Nyx Fast");
println!(" • Maximum 4X quality: RXL");
println!(" • HDR content: Hyperion");
println!(" • Slow motion: Apollo/Chronos");
println!(" • Ultra-slow motion: Aion");
println!("\n✅ Benchmarks demo completed successfully!");
println!("\nKey Features Demonstrated:");
println!(" • Comprehensive AI engine benchmarking");
println!(" • Scale-specific performance testing");
println!(" • Frame interpolation benchmarks");
println!(" • Benchmark mode optimization");
println!(" • Engine capability comparison");
println!(" • Performance-focused command generation");
Ok(())
}