Fix Topaz Video AI FFmpeg filter parameter errors
- Fix tvai_stb filter parameter names: method -> full, smooth -> smoothness - Fix tvai_fi filter fps parameter: Skip fps=0 to avoid parse errors - Resolve FFmpeg execution errors for stabilization and frame interpolation
This commit is contained in:
parent
0f19b416ae
commit
41c54098e8
|
|
@ -542,23 +542,31 @@ impl FfmpegCommandGenerator {
|
||||||
// 使用默认的稳定化模型
|
// 使用默认的稳定化模型
|
||||||
params.push("model=ref-2".to_string());
|
params.push("model=ref-2".to_string());
|
||||||
|
|
||||||
// 映射方法(0: 自动裁剪, 1: 无裁剪/全帧)
|
// 映射稳定化方法(0: 自动裁剪, 1: 全帧稳定化)
|
||||||
let method = if settings.method == 0 { "auto_crop" } else { "no_crop" };
|
let full_frame = if settings.method == 0 { 0 } else { 1 };
|
||||||
params.push(format!("method={}", method));
|
params.push(format!("full={}", full_frame));
|
||||||
|
|
||||||
// 映射平滑度(模板中为 0-100)
|
// 映射平滑度(模板中为 0-100,转换为 0-16 范围)
|
||||||
params.push(format!("smooth={}", settings.smooth));
|
let smoothness = (settings.smooth as f64 / 100.0 * 16.0).min(16.0);
|
||||||
|
params.push(format!("smoothness={:.1}", smoothness));
|
||||||
|
|
||||||
// 滚动快门校正
|
// 滚动快门校正
|
||||||
if settings.rsc {
|
if settings.rsc {
|
||||||
params.push("rsc=1".to_string());
|
params.push("roll=1".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 减少运动
|
// 减少运动抖动
|
||||||
if settings.reduce_motion {
|
if settings.reduce_motion {
|
||||||
params.push(format!("reduce_motion={}", settings.reduce_motion_iteration));
|
let reduce_level = settings.reduce_motion_iteration.min(5);
|
||||||
|
params.push(format!("reduce={}", reduce_level));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 调试信息
|
||||||
|
println!("生成 tvai_stb 滤镜参数: {:?}", params);
|
||||||
|
println!("稳定化设置: smoothness={:.1}, full={}, roll={}, reduce={}",
|
||||||
|
smoothness, full_frame, settings.rsc,
|
||||||
|
if settings.reduce_motion { settings.reduce_motion_iteration } else { 0 });
|
||||||
|
|
||||||
Ok(format!("tvai_stb={}", params.join(":")))
|
Ok(format!("tvai_stb={}", params.join(":")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -696,10 +704,17 @@ impl FfmpegCommandGenerator {
|
||||||
params.push(format!("slowmo={}", slowmo_settings.factor));
|
params.push(format!("slowmo={}", slowmo_settings.factor));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果指定了输出 FPS,设置参数
|
// 设置输出帧率(video_rate 格式)
|
||||||
if output_settings.out_fps > 0.0 {
|
if output_settings.out_fps > 0.0 {
|
||||||
params.push(format!("fps={}", output_settings.out_fps));
|
// 将浮点数转换为分数格式,例如 60.0 -> "60/1"
|
||||||
|
if output_settings.out_fps.fract() == 0.0 {
|
||||||
|
params.push(format!("fps={}/1", output_settings.out_fps as i32));
|
||||||
|
} else {
|
||||||
|
// 对于非整数帧率,使用更精确的分数表示
|
||||||
|
params.push(format!("fps={:.3}", output_settings.out_fps));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// 注意:当 out_fps 为 0 时,不添加 fps 参数,让 tvai_fi 使用默认的 "0" 值
|
||||||
|
|
||||||
// 重复帧阈值(rdt 参数)
|
// 重复帧阈值(rdt 参数)
|
||||||
if !slowmo_settings.duplicate {
|
if !slowmo_settings.duplicate {
|
||||||
|
|
@ -709,6 +724,10 @@ impl FfmpegCommandGenerator {
|
||||||
params.push(format!("rdt={:.3}", threshold));
|
params.push(format!("rdt={:.3}", threshold));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 调试信息
|
||||||
|
println!("生成 tvai_fi 滤镜参数: {:?}", params);
|
||||||
|
println!("输出 FPS: {}, 慢动作因子: {}", output_settings.out_fps, slowmo_settings.factor);
|
||||||
|
|
||||||
Ok(format!("tvai_fi={}", params.join(":")))
|
Ok(format!("tvai_fi={}", params.join(":")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1140,10 +1140,10 @@ impl TopazTemplateManager {
|
||||||
|
|
||||||
// Apply stabilization
|
// Apply stabilization
|
||||||
if template.settings.stabilize.active {
|
if template.settings.stabilize.active {
|
||||||
let method = if template.settings.stabilize.method == 0 { "auto_crop" } else { "no_crop" };
|
let full_frame = if template.settings.stabilize.method == 0 { 0 } else { 1 };
|
||||||
let smooth = template.settings.stabilize.smooth;
|
let smoothness = (template.settings.stabilize.smooth as f64 / 100.0 * 16.0).min(16.0);
|
||||||
|
|
||||||
let stabilize_filter = format!("tvai_stab=method={}:smooth={}", method, smooth);
|
let stabilize_filter = format!("tvai_stb=model=ref-2:full={}:smoothness={:.1}", full_frame, smoothness);
|
||||||
filters.push(stabilize_filter);
|
filters.push(stabilize_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1755,10 +1755,10 @@ impl TopazTemplateManager {
|
||||||
|
|
||||||
// Apply stabilization
|
// Apply stabilization
|
||||||
if template.settings.stabilize.active {
|
if template.settings.stabilize.active {
|
||||||
let method = if template.settings.stabilize.method == 0 { "auto_crop" } else { "no_crop" };
|
let full_frame = if template.settings.stabilize.method == 0 { 0 } else { 1 };
|
||||||
let smooth = template.settings.stabilize.smooth;
|
let smoothness = (template.settings.stabilize.smooth as f64 / 100.0 * 16.0).min(16.0);
|
||||||
|
|
||||||
let stabilization_filter = format!("tvai_stab=method={}:smooth={}", method, smooth);
|
let stabilization_filter = format!("tvai_stb=model=ref-2:full={}:smoothness={:.1}", full_frame, smoothness);
|
||||||
filters.push(stabilization_filter);
|
filters.push(stabilization_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1824,7 +1824,9 @@ impl TopazTemplateManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(fps) = opts.target_fps {
|
if let Some(fps) = opts.target_fps {
|
||||||
fi_filter.push_str(&format!(":fps={}", fps));
|
if fps > 0 {
|
||||||
|
fi_filter.push_str(&format!(":fps={}", fps));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fi_filter.push_str(&format!(
|
fi_filter.push_str(&format!(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue