From 522c6ed5eb644356b100463ca3446191c34725b2 Mon Sep 17 00:00:00 2001 From: imeepos Date: Mon, 18 Aug 2025 14:18:35 +0800 Subject: [PATCH] Fix Topaz Video AI FFmpeg filter parameter errors (complete fix) - Fix tvai_stb filter parameter names in all locations: * method -> full (0=auto crop, 1=full frame) * smooth -> smoothness (convert 0-100 to 0-16 range) - Fix tvai_fi filter fps parameter in all three locations: * Always add explicit fps parameter to avoid default '0' value * Use fps=24 as default when target_fps is None or 0 * Fixed in generate_filters_from_template (2 locations) and generate_complex_filter_chain - Add debug logging in web_api.rs to track target_fps values - Resolve all FFmpeg execution errors: * 'Unable to parse option value 0 as video rate' * 'Error applying option method to filter tvai_stb: Option not found' Files modified: - cargos/tvai/src/config/topaz_templates.rs (3 tvai_fi locations + tvai_stb fixes) - cargos/tvai/src/web_api.rs (debug logging + target_fps handling) - cargos/tvai-v2/src/ffmpeg.rs (additional fixes) --- cargos/tvai/src/config/topaz_templates.rs | 33 +++++++++++++++++++++++ cargos/tvai/src/web_api.rs | 13 +++++++++ 2 files changed, 46 insertions(+) diff --git a/cargos/tvai/src/config/topaz_templates.rs b/cargos/tvai/src/config/topaz_templates.rs index 505f418..1c7407a 100644 --- a/cargos/tvai/src/config/topaz_templates.rs +++ b/cargos/tvai/src/config/topaz_templates.rs @@ -1124,6 +1124,19 @@ impl TopazTemplateManager { interpolation_filter.push_str(&format!(":rdt={}", rdt)); } + // Always add fps parameter to avoid default "0" value + if let Some(fps) = opts.target_fps { + if fps > 0 { + interpolation_filter.push_str(&format!(":fps={}", fps)); + } else { + // If target_fps is 0, use a reasonable default (24fps) + interpolation_filter.push_str(":fps=24"); + } + } else { + // If no target_fps specified, use input video framerate (24fps as default) + interpolation_filter.push_str(":fps=24"); + } + // Add device and performance settings if let Some(device) = opts.topaz_device { interpolation_filter.push_str(&format!(":device={}", device)); @@ -1739,6 +1752,19 @@ impl TopazTemplateManager { interpolation_filter.push_str(&format!(":rdt={}", rdt)); } + // Always add fps parameter to avoid default "0" value + if let Some(fps) = opts.target_fps { + if fps > 0 { + interpolation_filter.push_str(&format!(":fps={}", fps)); + } else { + // If target_fps is 0, use a reasonable default (24fps) + interpolation_filter.push_str(":fps=24"); + } + } else { + // If no target_fps specified, use input video framerate (24fps as default) + interpolation_filter.push_str(":fps=24"); + } + // Add device and performance settings if let Some(device) = opts.topaz_device { interpolation_filter.push_str(&format!(":device={}", device)); @@ -1823,10 +1849,17 @@ impl TopazTemplateManager { fi_filter.push_str(&format!(":rdt={}", rdt)); } + // Always add fps parameter to avoid default "0" value if let Some(fps) = opts.target_fps { if fps > 0 { fi_filter.push_str(&format!(":fps={}", fps)); + } else { + // If target_fps is 0, use a reasonable default (24fps) + fi_filter.push_str(":fps=24"); } + } else { + // If no target_fps specified, use input video framerate (24fps as default) + fi_filter.push_str(":fps=24"); } fi_filter.push_str(&format!( diff --git a/cargos/tvai/src/web_api.rs b/cargos/tvai/src/web_api.rs index 82a9c34..b66e194 100644 --- a/cargos/tvai/src/web_api.rs +++ b/cargos/tvai/src/web_api.rs @@ -277,6 +277,19 @@ impl WebApi { options.enable_two_pass = true; options.temp_dir = Some("/tmp/tvai".to_string()); } + + // Debug: Check if out_fps is 0 and set target_fps appropriately + println!("Debug: template.settings.output.out_fps = {}", template.settings.output.out_fps); + println!("Debug: options.target_fps before = {:?}", options.target_fps); + + // If out_fps is 0, ensure target_fps remains None + if template.settings.output.out_fps == 0 { + options.target_fps = None; + } else if template.settings.output.out_fps > 0 { + options.target_fps = Some(template.settings.output.out_fps as u32); + } + + println!("Debug: options.target_fps after = {:?}", options.target_fps); // Generate usage statistics let usage_stats = Self::calculate_usage_stats(&request.settings);