feat: asrx recovery + pipeline fixes + face trace improvements
- ASR-ASRX unified processor (asr_asrx → asrx), output .asrx.json - ffmpeg -vsync → -fps_mode (swift_ocr, swift_hand, swift_pose, frame_cache) - ffprobe absolute path for probe - PYTHONPATH + PATH added to executor subprocesses - cut processor path fix (cut/cut_processor.py) - scene_vlm fallback when blur_scores empty + ffmpeg absolute path - rust_store_traced_faces generates key_face.jpg with --video-path - face group representative trace picks highest best_confidence - Studio: move FS doesn't remove from unassigned, always reload after move - Studio: confirmMoveFaceToNewGroup simplified to just rename - Studio: scene_vlm added to processors list - Studio: scene_vlm shows (0) when ready but no scenes - admin_config asr_config block added
This commit is contained in:
@@ -2135,7 +2135,7 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
||||
let tkg_edges_t = schema::table_name("tkg_edges");
|
||||
|
||||
let has_asr_or_asrx =
|
||||
job_processors.is_empty() || job_processors.iter().any(|p| p == "asrx" || p == "asr");
|
||||
job_processors.is_empty() || job_processors.iter().any(|p| p == "asrx" || p == "asr" || p == "asr_asrx");
|
||||
let has_face = job_processors.is_empty() || job_processors.iter().any(|p| p == "face");
|
||||
let has_cut = job_processors.is_empty() || job_processors.iter().any(|p| p == "cut");
|
||||
|
||||
@@ -2147,6 +2147,9 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
||||
UNION ALL \
|
||||
SELECT asr_status FROM {pr_t} pr JOIN {mj_t} mj ON pr.job_id = mj.id \
|
||||
WHERE mj.uuid = $1 AND pr.processor = 'asr' AND asr_status IS NOT NULL \
|
||||
UNION ALL \
|
||||
SELECT asr_status FROM {pr_t} pr JOIN {mj_t} mj ON pr.job_id = mj.id \
|
||||
WHERE mj.uuid = $1 AND pr.processor = 'asr_asrx' AND asr_status IS NOT NULL \
|
||||
LIMIT 1",
|
||||
mj_t = schema::table_name("monitor_jobs")
|
||||
))
|
||||
@@ -2172,7 +2175,7 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
||||
if status_from_db {
|
||||
true
|
||||
} else {
|
||||
// Fallback: check asr.json file directly
|
||||
// Fallback: check asr.json / asr_asrx.json file directly
|
||||
let asr_path = format!(
|
||||
"{}/{}.asr.json",
|
||||
crate::core::config::OUTPUT_DIR
|
||||
@@ -2180,7 +2183,16 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
||||
.trim_end_matches('/'),
|
||||
uuid
|
||||
);
|
||||
if let Ok(content) = std::fs::read_to_string(&asr_path) {
|
||||
let asr_asrx_path = format!(
|
||||
"{}/{}.asr_asrx.json",
|
||||
crate::core::config::OUTPUT_DIR
|
||||
.as_str()
|
||||
.trim_end_matches('/'),
|
||||
uuid
|
||||
);
|
||||
let content = std::fs::read_to_string(&asr_path)
|
||||
.or_else(|_| std::fs::read_to_string(&asr_asrx_path));
|
||||
if let Ok(content) = content {
|
||||
if let Ok(data) = serde_json::from_str::<serde_json::Value>(&content) {
|
||||
match data.get("status").and_then(|s| s.as_str()) {
|
||||
Some("no_audio_track") | Some("silent_audio") => true,
|
||||
@@ -2397,6 +2409,7 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
||||
// (completed + failed) == total_scenes 才代表全部 scene 都處理完,
|
||||
// 否則 job 保持 running 由 poll 重試。
|
||||
let scene_vlm_done: bool = if has_cut {
|
||||
// Check if scenes.json exists first
|
||||
if let Ok(scenes_json) =
|
||||
std::fs::read_to_string(format!("{}/{}.scenes.json", output_dir, uuid))
|
||||
{
|
||||
@@ -2406,7 +2419,6 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
||||
.and_then(|v| v.as_i64())
|
||||
.unwrap_or(0);
|
||||
if total == 0 {
|
||||
// 無 scene 可選(例如極短或全部 blur 失敗)視為完成
|
||||
true
|
||||
} else {
|
||||
let completed = scenes_data
|
||||
@@ -2429,7 +2441,18 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
false
|
||||
// scenes.json not found — check processor_results for scene_vlm completion
|
||||
// (e.g. "completed" due to invalid metadata / not applicable)
|
||||
let mj_t = schema::table_name("monitor_jobs");
|
||||
let pr_t = schema::table_name("processor_results");
|
||||
let svlm_done: Option<String> = sqlx::query_scalar(&format!(
|
||||
"SELECT status FROM {pr_t} WHERE job_id = (SELECT id FROM {mj_t} WHERE uuid = $1) AND processor = 'scene_vlm' LIMIT 1"
|
||||
))
|
||||
.bind(uuid)
|
||||
.fetch_optional(pool)
|
||||
.await
|
||||
.unwrap_or(None);
|
||||
svlm_done.as_deref() == Some("completed")
|
||||
}
|
||||
} else {
|
||||
true
|
||||
@@ -2532,7 +2555,7 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
||||
// 例如:Rule 1 只需 ASR+ASRX 完成即可觸發,不須等 face/pose/story 完成
|
||||
|
||||
// 定義必要 processor(必須完成的才算 job 成功)
|
||||
let essential_processors = ["cut", "asr", "asrx"];
|
||||
let essential_processors = ["cut", "asr", "asrx", "asr_asrx"];
|
||||
|
||||
let essential_failed = essential_processors.iter().any(|ep| {
|
||||
results.iter().any(|r| {
|
||||
@@ -2911,8 +2934,8 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
||||
|
||||
let has_asr_or_asrx = completed_processors
|
||||
.iter()
|
||||
.any(|p| p == "asrx" || p == "asr");
|
||||
let has_asrx = completed_processors.iter().any(|p| p == "asrx");
|
||||
.any(|p| p == "asrx" || p == "asr" || p == "asr_asrx");
|
||||
let has_asrx = completed_processors.iter().any(|p| p == "asrx" || p == "asr_asrx");
|
||||
let has_cut = completed_processors.iter().any(|p| p == "cut");
|
||||
let has_face = completed_processors.iter().any(|p| p == "face");
|
||||
let has_ocr = completed_processors.iter().any(|p| p == "ocr");
|
||||
@@ -3376,13 +3399,27 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> {
|
||||
|
||||
let output_dir = crate::core::config::OUTPUT_DIR.as_str();
|
||||
|
||||
// Get video path from DB for face crop extraction
|
||||
let video_path: Option<String> = db_clone
|
||||
.get_video_by_uuid(&uuid_clone)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|v| v.file_path);
|
||||
|
||||
let mut face_args = vec![uuid_clone.as_str(), "--output-dir", output_dir];
|
||||
if let Some(ref vp) = video_path {
|
||||
face_args.push("--video-path");
|
||||
face_args.push(vp.as_str());
|
||||
}
|
||||
|
||||
let result = match executor.rust_binary_path("rust_store_traced_faces") {
|
||||
Some(bin) => {
|
||||
tracing::info!("[FACE_TRACE] Using Rust binary: {:?}", bin);
|
||||
executor
|
||||
.run_rust_with_output_idx_and_frames(
|
||||
&bin,
|
||||
&[&uuid_clone, "--output-dir", output_dir],
|
||||
&face_args,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
|
||||
@@ -1098,6 +1098,62 @@ impl ProcessorPool {
|
||||
total_faces: 0,
|
||||
})
|
||||
}
|
||||
ProcessorType::AsrAsrx => {
|
||||
let asr_asrx_result = processor::process_asr_asrx(
|
||||
video_path,
|
||||
output_path.to_str().unwrap(),
|
||||
uuid,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Convert to AsrResult for storage
|
||||
let asr_segments: Vec<processor::AsrSegment> = asr_asrx_result
|
||||
.segments
|
||||
.iter()
|
||||
.map(|s| processor::AsrSegment {
|
||||
start_time: s.start,
|
||||
end_time: s.end,
|
||||
start_frame: None,
|
||||
end_frame: None,
|
||||
text: s.text.clone(),
|
||||
confidence: 1.0,
|
||||
})
|
||||
.collect();
|
||||
|
||||
let mut asr_result = processor::AsrResult {
|
||||
metadata: None,
|
||||
status: None,
|
||||
language: Some(asr_asrx_result.language.clone()),
|
||||
language_probability: None,
|
||||
segments: asr_segments,
|
||||
segment_count: 0,
|
||||
};
|
||||
asr_result.compute_status();
|
||||
|
||||
let chunks_produced = asr_result.segments.len() as i32;
|
||||
let lang = asr_result.language.clone();
|
||||
tracing::info!(
|
||||
"ASR_ASRX completed, language={}, {} segments for {}",
|
||||
lang.as_deref().unwrap_or("unknown"),
|
||||
chunks_produced,
|
||||
job.uuid
|
||||
);
|
||||
if let Err(e) = Self::store_asr_chunks(db, &job.uuid, &asr_result).await {
|
||||
tracing::error!("Failed to store ASR_ASRX chunks for {}: {}", job.uuid, e);
|
||||
}
|
||||
Ok(ProcessorOutput {
|
||||
data: serde_json::Value::Null,
|
||||
chunks_produced,
|
||||
frames_processed: total_frames,
|
||||
total_frames,
|
||||
retry_count: 0,
|
||||
pid: 0,
|
||||
asr_status: asr_result.status.clone(),
|
||||
segment_count: asr_result.segment_count,
|
||||
face_status: None,
|
||||
total_faces: 0,
|
||||
})
|
||||
}
|
||||
ProcessorType::Asrx => {
|
||||
let mut result =
|
||||
processor::process_asrx(video_path, output_path.to_str().unwrap(), uuid)
|
||||
|
||||
Reference in New Issue
Block a user