콘텐츠로 이동

register_captions_batch

여러 비디오 캡션 배치 등록


개요

JSON 파일을 읽어 여러 비디오의 캡션을 순차적으로 등록합니다.


Function Signature

def register_captions_batch(
    feature_view: str,
    json_file_path: str
) -> Dict[str, Any]

Description

JSON 파일을 읽어 여러 비디오의 캡션을 순차적으로 등록합니다. 파일이 올바르지 않을 시 등록이 시작되지 않습니다.


Parameters

Parameter Type Default Description
json_file_path str required 등록할 비디오 정보를 담은 JSON 파일 경로

JSON Schema

필수 필드: uuid, mp4_source, model, segments
선택 필드: config, timestamp

[
    {
        "uuid": "video-001",
        "mp4_source": "/path/to/video.mp4",
        "model": "gpt-4o",
        "segments": [
            {"index": 0, "start": 0.0, "end": 10.0, "text": "..."}
        ],
        "config": null,
        "timestamp": "2026-01-15T10:00:00+00:00"
    }
]

참고

config, timestamp 필드가 아예 없어도 정상 동작합니다.


Returns

Type: Dict[str, Any]

{
    'total': 3,       # 총 등록 시도 개수
    'success': 3,     # 성공 개수
    'failed': 0,      # 실패 개수
    'results': [...]  # 상세 결과
}

Validation 에러

Validation 에러는 함수 실행 전에 ValueError로 발생하므로,
failed는 실행 중 발생한 에러(네트워크 오류, 파일 없음 등)만 포함합니다.


예시

3개 비디오 배치 등록

batch.json 파일:

[
    {
        "uuid": "f2c99e03-8415-4926-bf3d-60ec8c2ddab4",
        "mp4_source": "https://www.youtube.com/watch?v=eMlx5fFNoYc",
        "model": "gpt-4o",
        "segments": [
            {"index": 0, "start": 0.0, "end": 10.0, "text": "First segment"},
            {"index": 1, "start": 10.0, "end": 20.0, "text": "Second segment"}
        ]
    },
    {
        "uuid": "1d0f4f13-f79b-448b-b176-cbcc4f38e911",
        "mp4_source": "https://www.youtube.com/watch?v=GrfWYtOKd5c",
        "model": "gpt-4o",
        "segments": [
            {"index": 0, "start": 0.0, "end": 15.0, "text": "Another video"}
        ]
    },
    {
        "uuid": "a1b2c3d4-5678-90ab-cdef-123456789abc",
        "mp4_source": "https://www.youtube.com/watch?v=_vJ34QNTero",
        "model": "gpt-4o",
        "segments": [
            {"index": 0, "start": 0.0, "end": 5.0, "text": "Opening"},
            {"index": 1, "start": 5.0, "end": 10.0, "text": "Middle"},
            {"index": 2, "start": 10.0, "end": 15.0, "text": "Ending"}
        ]
    }
]

배치 등록:

# 배치 등록
result = api.register_captions_batch(
    feature_view='caption_summary',
    json_file_path='batch.json'
)

print(f"Total: {result['total']}")
print(f"Success: {result['success']}")
print(f"Failed: {result['failed']}")

출력:

Total: 3
Success: 3
Failed: 0

results 상세:
  index  uuid                                     model    status    segment_count
  0      f2c99e03-8415-4926-bf3d-60ec8c2ddab4     gpt-4o   success   2
  1      1d0f4f13-f79b-448b-b176-cbcc4f38e911     gpt-4o   success   1
  2      a1b2c3d4-5678-90ab-cdef-123456789abc     gpt-4o   success   3


관련 API