feat: update pose and face processors to use tool.args
改進:
- pose.rs: Rust 和 Swift 支持 tool.args
- face.rs: Swift 支持 tool.args
邏輯:
- 如果 tool.args 不為空,使用配置中的 args
- 否則,使用舊的手動構建方式(向後兼容)
優勢:
- 參數配置化(從 config 讀取)
- 減少硬編碼
- 支持 V3 配置變量替換
示例:
- V3 config: args = ["--video", "{video_path}", "--output", "{output_path}"]
- 變量替換: {video_path} → /path/to/video.mp4
- 最終 args: ["--video", "/path/to/video.mp4", "--output", "/path/to/output.json"]
下一步:
- 測試完整流程
- 驗證 V3 配置工作
This commit is contained in:
@@ -358,11 +358,17 @@ async fn run_face_with_config(
|
||||
let swift_path = &tool.path;
|
||||
tracing::info!("[FACE] Using Swift processor from config: {:?}", swift_path);
|
||||
|
||||
let mut args = vec![video_path.to_string(), output_path.to_string()];
|
||||
if let Some(u) = uuid {
|
||||
args.push("--uuid".to_string());
|
||||
args.push(u.to_string());
|
||||
}
|
||||
let args = if !tool.args.is_empty() {
|
||||
tracing::info!("[FACE] Using args from config: {:?}", tool.args);
|
||||
tool.args.clone()
|
||||
} else {
|
||||
let mut args = vec![video_path.to_string(), output_path.to_string()];
|
||||
if let Some(u) = uuid {
|
||||
args.push("--uuid".to_string());
|
||||
args.push(u.to_string());
|
||||
}
|
||||
args
|
||||
};
|
||||
|
||||
let output = tokio::process::Command::new(swift_path)
|
||||
.args(&args)
|
||||
|
||||
+39
-17
@@ -524,11 +524,17 @@ async fn run_pose_with_config(
|
||||
let swift_path = &tool.path;
|
||||
tracing::info!("[POSE] Using Swift processor from config: {:?}", swift_path);
|
||||
|
||||
let mut args = vec![video_path.to_string(), output_path.to_string()];
|
||||
if let Some(u) = uuid {
|
||||
args.push("--uuid".to_string());
|
||||
args.push(u.to_string());
|
||||
}
|
||||
let args = if !tool.args.is_empty() {
|
||||
tracing::info!("[POSE] Using args from config: {:?}", tool.args);
|
||||
tool.args.clone()
|
||||
} else {
|
||||
let mut args = vec![video_path.to_string(), output_path.to_string()];
|
||||
if let Some(u) = uuid {
|
||||
args.push("--uuid".to_string());
|
||||
args.push(u.to_string());
|
||||
}
|
||||
args
|
||||
};
|
||||
|
||||
let output = tokio::process::Command::new(swift_path)
|
||||
.args(&args)
|
||||
@@ -553,18 +559,34 @@ async fn run_pose_with_config(
|
||||
let rust_path = &tool.path;
|
||||
tracing::info!("[POSE] Using Rust processor from config: {:?}", rust_path);
|
||||
|
||||
executor
|
||||
.run_rust_with_output_idx_and_frames(
|
||||
rust_path,
|
||||
&[video_path, output_path, output_path],
|
||||
Some(2),
|
||||
uuid,
|
||||
None,
|
||||
"POSE",
|
||||
Some(POSE_TIMEOUT),
|
||||
)
|
||||
.await
|
||||
.with_context(|| format!("Failed to run Rust binary {:?}", rust_path))?;
|
||||
if !tool.args.is_empty() {
|
||||
tracing::info!("[POSE] Using args from config: {:?}", tool.args);
|
||||
|
||||
let output = tokio::process::Command::new(rust_path)
|
||||
.args(&tool.args)
|
||||
.output()
|
||||
.await
|
||||
.context("Failed to execute rust_pose")?;
|
||||
|
||||
if !output.status.success() {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
tracing::error!("[POSE] Rust processor failed: {}", stderr);
|
||||
anyhow::bail!("Rust pose processor failed");
|
||||
}
|
||||
} else {
|
||||
executor
|
||||
.run_rust_with_output_idx_and_frames(
|
||||
rust_path,
|
||||
&[video_path, output_path, output_path],
|
||||
Some(2),
|
||||
uuid,
|
||||
None,
|
||||
"POSE",
|
||||
Some(POSE_TIMEOUT),
|
||||
)
|
||||
.await
|
||||
.with_context(|| format!("Failed to run Rust binary {:?}", rust_path))?;
|
||||
}
|
||||
|
||||
let json_str = std::fs::read_to_string(output_path)
|
||||
.context("Failed to read POSE output")?;
|
||||
|
||||
Reference in New Issue
Block a user