feat: 新增 Job Worker 系統與 API 文檔全面更新
This commit is contained in:
@@ -8,6 +8,7 @@ use std::sync::{Arc, Mutex};
|
||||
use momentry_core::core::api_key::{ApiKeyService, ApiKeyType};
|
||||
use momentry_core::core::chunk::types::{Chunk, ChunkRule, ChunkType};
|
||||
use momentry_core::core::db::Database;
|
||||
use momentry_core::core::time::FrameTime;
|
||||
use momentry_core::ui::progress::{ProcessorType, ProgressState, ProgressUi};
|
||||
use momentry_core::{
|
||||
Embedder, OutputDir, PostgresDb, QdrantDb, RedisClient, VectorPayload, VideoRecord, VideoStatus,
|
||||
@@ -1818,16 +1819,14 @@ async fn main() -> Result<()> {
|
||||
// Store ASR sentence pre_chunks
|
||||
let mut asr_pre_chunk_ids = Vec::new();
|
||||
for seg in asr_result.segments.iter() {
|
||||
let start_frame = (seg.start * fps) as i64;
|
||||
let end_frame = (seg.end * fps) as i64;
|
||||
let start_frame = FrameTime::from_seconds(seg.start, fps).frames();
|
||||
let end_frame = FrameTime::from_seconds(seg.end, fps).frames();
|
||||
let pre_chunk = momentry_core::core::db::postgres_db::PreChunk {
|
||||
id: 0,
|
||||
file_id,
|
||||
source_type: "asr".to_string(),
|
||||
source_file: Some(asr_path.clone()),
|
||||
chunk_type: "sentence".to_string(),
|
||||
start_time: seg.start,
|
||||
end_time: seg.end,
|
||||
start_frame,
|
||||
end_frame,
|
||||
fps,
|
||||
@@ -1850,8 +1849,6 @@ async fn main() -> Result<()> {
|
||||
source_type: "cut".to_string(),
|
||||
source_file: Some(cut_path.clone()),
|
||||
chunk_type: "cut".to_string(),
|
||||
start_time: scene.start_time,
|
||||
end_time: scene.end_time,
|
||||
start_frame: scene.start_frame as i64,
|
||||
end_frame: scene.end_frame as i64,
|
||||
fps,
|
||||
@@ -1873,8 +1870,8 @@ async fn main() -> Result<()> {
|
||||
let mut time_start = 0.0;
|
||||
while time_start < duration {
|
||||
let time_end = (time_start + 10.0).min(duration);
|
||||
let start_frame = (time_start * fps) as i64;
|
||||
let end_frame = (time_end * fps) as i64;
|
||||
let start_frame = FrameTime::from_seconds(time_start, fps).frames();
|
||||
let end_frame = FrameTime::from_seconds(time_end, fps).frames();
|
||||
|
||||
let pre_chunk = momentry_core::core::db::postgres_db::PreChunk {
|
||||
id: 0,
|
||||
@@ -1882,8 +1879,6 @@ async fn main() -> Result<()> {
|
||||
source_type: "time".to_string(),
|
||||
source_file: None,
|
||||
chunk_type: "time".to_string(),
|
||||
start_time: time_start,
|
||||
end_time: time_end,
|
||||
start_frame,
|
||||
end_frame,
|
||||
fps,
|
||||
@@ -1975,7 +1970,7 @@ async fn main() -> Result<()> {
|
||||
let mut sentence_chunks = Vec::new();
|
||||
for (i, seg) in asr_result.segments.iter().enumerate() {
|
||||
let pre_chunk_id = asr_pre_chunk_ids.get(i).copied().unwrap_or(0);
|
||||
let chunk = Chunk::new(
|
||||
let chunk = Chunk::from_seconds(
|
||||
file_id as i32,
|
||||
uuid.clone(),
|
||||
i as u32,
|
||||
@@ -1997,7 +1992,7 @@ async fn main() -> Result<()> {
|
||||
let mut cut_chunks = Vec::new();
|
||||
for (i, scene) in cut_result.scenes.iter().enumerate() {
|
||||
let pre_chunk_id = cut_pre_chunk_ids.get(i).copied().unwrap_or(0);
|
||||
let chunk = Chunk::new(
|
||||
let chunk = Chunk::from_seconds(
|
||||
file_id as i32,
|
||||
uuid.clone(),
|
||||
i as u32,
|
||||
@@ -2026,8 +2021,8 @@ async fn main() -> Result<()> {
|
||||
i as u32,
|
||||
ChunkType::TimeBased,
|
||||
ChunkRule::Rule1,
|
||||
tc.start_time,
|
||||
tc.end_time,
|
||||
tc.start_frame,
|
||||
tc.end_frame,
|
||||
fps,
|
||||
serde_json::json!({"interval": 10.0}),
|
||||
)
|
||||
@@ -2117,12 +2112,13 @@ async fn main() -> Result<()> {
|
||||
println!("\n=== Scene {} ===", i + 1);
|
||||
println!(
|
||||
"Time: {:.2}s - {:.2}s",
|
||||
story_chunk.start_time, story_chunk.end_time
|
||||
story_chunk.start_time().seconds(),
|
||||
story_chunk.end_time().seconds()
|
||||
);
|
||||
|
||||
// Get context: expand time range by 5 seconds before and after
|
||||
let context_start = (story_chunk.start_time - 5.0).max(0.0);
|
||||
let context_end = (story_chunk.end_time + 5.0).min(duration);
|
||||
let context_start = (story_chunk.start_time().seconds() - 5.0).max(0.0);
|
||||
let context_end = (story_chunk.end_time().seconds() + 5.0).min(duration);
|
||||
|
||||
// Get chunks in context range (sentence chunks with ASR text)
|
||||
let context_chunks = db
|
||||
@@ -2139,8 +2135,8 @@ async fn main() -> Result<()> {
|
||||
story.push_str(&format!(
|
||||
"Scene {} ({:.1}s - {:.1}s)\n\n",
|
||||
i + 1,
|
||||
story_chunk.start_time,
|
||||
story_chunk.end_time
|
||||
story_chunk.start_time().seconds(),
|
||||
story_chunk.end_time().seconds()
|
||||
));
|
||||
|
||||
// Add audio/text content
|
||||
@@ -2290,8 +2286,8 @@ async fn main() -> Result<()> {
|
||||
uuid: chunk.uuid.clone(),
|
||||
chunk_id: chunk.chunk_id.clone(),
|
||||
chunk_type: "sentence".to_string(),
|
||||
start_time: chunk.start_time,
|
||||
end_time: chunk.end_time,
|
||||
start_time: chunk.start_time().seconds(),
|
||||
end_time: chunk.end_time().seconds(),
|
||||
text: Some(text.to_string()),
|
||||
};
|
||||
if let Err(e) = qdrant
|
||||
|
||||
Reference in New Issue
Block a user