feat: 新增代码
This commit is contained in:
24
video_worker/app/utils/files.py
Normal file
24
video_worker/app/utils/files.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
|
||||
TASK_VIDEO_NAME = "video.mp4"
|
||||
TASK_FIRST_FRAME_NAME = "first_frame.jpg"
|
||||
TASK_METADATA_NAME = "metadata.json"
|
||||
TASK_LOG_NAME = "run.log"
|
||||
|
||||
|
||||
def ensure_dir(path: Path) -> Path:
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
return path
|
||||
|
||||
|
||||
def task_output_dir(base_output_dir: Path, task_id: str) -> Path:
|
||||
return ensure_dir(base_output_dir / task_id)
|
||||
|
||||
|
||||
def write_json(path: Path, data: Dict[str, Any]) -> None:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with path.open("w", encoding="utf-8") as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=2)
|
||||
Reference in New Issue
Block a user