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)
This commit is contained in:
imeepos 2025-08-18 14:18:35 +08:00
parent 41c54098e8
commit 522c6ed5eb
2 changed files with 46 additions and 0 deletions

View File

@ -1124,6 +1124,19 @@ impl TopazTemplateManager {
interpolation_filter.push_str(&format!(":rdt={}", rdt)); 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 // Add device and performance settings
if let Some(device) = opts.topaz_device { if let Some(device) = opts.topaz_device {
interpolation_filter.push_str(&format!(":device={}", device)); interpolation_filter.push_str(&format!(":device={}", device));
@ -1739,6 +1752,19 @@ impl TopazTemplateManager {
interpolation_filter.push_str(&format!(":rdt={}", rdt)); 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 // Add device and performance settings
if let Some(device) = opts.topaz_device { if let Some(device) = opts.topaz_device {
interpolation_filter.push_str(&format!(":device={}", device)); interpolation_filter.push_str(&format!(":device={}", device));
@ -1823,10 +1849,17 @@ impl TopazTemplateManager {
fi_filter.push_str(&format!(":rdt={}", rdt)); fi_filter.push_str(&format!(":rdt={}", rdt));
} }
// Always add fps parameter to avoid default "0" value
if let Some(fps) = opts.target_fps { if let Some(fps) = opts.target_fps {
if fps > 0 { if fps > 0 {
fi_filter.push_str(&format!(":fps={}", fps)); 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!( fi_filter.push_str(&format!(

View File

@ -277,6 +277,19 @@ impl WebApi {
options.enable_two_pass = true; options.enable_two_pass = true;
options.temp_dir = Some("/tmp/tvai".to_string()); 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 // Generate usage statistics
let usage_stats = Self::calculate_usage_stats(&request.settings); let usage_stats = Self::calculate_usage_stats(&request.settings);