register_captions¶
단일 비디오 캡션 등록
개요¶
외부 모델(GPT-4, Claude, Gemini 등)로 생성한 캡션 데이터를 Feature Store에 수동 등록합니다.
Function Signature¶
def register_captions(
feature_view: str,
uuid: str,
mp4_source: str,
model: str,
segments: List[Dict[str, Any]],
config: Optional[str] = None,
timestamp: Optional[str] = None
) -> Dict[str, Any]
Description¶
외부 모델(GPT-4, Claude, Gemini 등)로 생성한 캡션 데이터를 Feature Store에 수동 등록합니다.
Notes:
- 비디오 정보가 없으면 video Feature View에 자동으로 등록함
- 로컬 비디오와 YouTube 비디오 모두 지원
- Feature Store와 Metadata Store에 동시 저장됨
- Config 경로를 사용자가 임의로 지정해도 설정 파일은 자동으로 특정 경로에 저장됨
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
uuid |
str |
required | 비디오 고유 식별자 예: "f2c99e03-8415-4926-bf3d-60ec8c2ddab4" |
mp4_source |
str |
required | 로컬 경로 또는 YouTube URL • 로컬: /gpfs/public/artifacts/videos/video-001/content.mp4• YouTube: https://www.youtube.com/watch?v=VIDEO_ID |
model |
str |
required | 캡션 생성 모델 이름 예: "gpt-4o", "claude-3.5", "gemini-pro" |
segments |
List[Dict] |
required | 캡션 세그먼트 리스트 각 세그먼트는 4개 필드 포함: index, start, end, text |
config |
str or None |
None |
Config 파일 경로 |
timestamp |
str or None |
None |
데이터 저장 시점 (ISO format)None이면 현재 시간 자동 사용 |
segments 형식¶
[
{"index": 0, "start": 0.0, "end": 10.0, "text": "A man is cooking..."},
{"index": 1, "start": 10.0, "end": 20.0, "text": "He chops vegetables..."},
{"index": 2, "start": 20.0, "end": 30.0, "text": "He adds ingredients..."}
]
Returns¶
Type: Dict[str, Any]
{
"status": str, # "success" or "error"
"uuid": str, # 입력한 uuid
"model": str, # 입력한 model
"config": str or None, # 입력한 config (None 가능)
"timestamp": str, # 저장된 timestamp
"segment_count": int, # 저장된 segment 개수
"video_registered": bool, # 비디오 자동 등록 여부
"file_size": int, # 비디오 파일 크기 (자동 계산)
"duration": float # 비디오 길이 (자동 계산)
}
예시¶
로컬 비디오 캡션 등록¶
# 캡션 등록 - 비디오 정보는 자동으로 등록됨
result = register_captions(
feature_view='caption_summary',
uuid='f2c99e03-8415-4926-bf3d-60ec8c2ddab4',
mp4_source='/gpfs/public/artifacts/videos/f2c99e03-8415-4926-bf3d-60ec8c2ddab4/content.mp4',
model='openai-gpt-4o',
segments=[
{"index": 0, "start": 0.0, "end": 10.0, "text": "A man is cooking..."},
{"index": 1, "start": 10.0, "end": 20.0, "text": "He chops vegetables..."},
{"index": 2, "start": 20.0, "end": 30.0, "text": "He adds ingredients..."}
]
)
print(f"Registered {result['segment_count']} segments")
출력:
{
"status": "success",
"uuid": "f2c99e03-8415-4926-bf3d-60ec8c2ddab4",
"model": "openai-gpt-4o",
"config": None,
"timestamp": "2024-12-26T16:00:00.123456",
"segment_count": 3,
"video_registered": True, # 비디오 자동 등록됨
"file_size": 13355607, # 자동 계산됨
"duration": 120.5 # 자동 계산됨
}
YouTube 비디오 캡션 등록¶
result = register_captions(
feature_view='caption_summary',
uuid='youtube-abc123',
mp4_source='https://www.youtube.com/watch?v=dQw4w9WgXcQ',
model='google-gemini-2.0-flash-exp',
segments=[
{"index": 0, "start": 0.0, "end": 15.0, "text": "Introduction to the topic..."},
{"index": 1, "start": 15.0, "end": 45.0, "text": "Detailed explanation..."},
{"index": 2, "start": 45.0, "end": 60.0, "text": "Conclusion and summary..."}
]
)
출력:
{
"status": "success",
"uuid": "youtube-abc123",
"model": "google-gemini-2.0-flash-exp",
"config": None,
"timestamp": "2024-12-26T17:30:00.456789",
"segment_count": 3,
"video_registered": True,
"file_size": 8234567, # YouTube metadata
"duration": 60.0 # YouTube metadata
}
관련 API¶
- register_captions_batch - 배치 등록
- get_captions - 등록된 캡션 조회