콘텐츠로 이동

register_captions_batch

Batch registration of captions for multiple videos.


Overview

Reads a JSON file and sequentially registers captions for multiple videos.


Function Signature

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

Description

Reads a JSON file and sequentially registers captions for multiple videos. Registration will not start if the file is invalid.


Parameters

Parameter Type Default Description
json_file_path str required Path to the JSON file containing the video information to be registered

JSON Schema

Required Fields: uuid, mp4_source, model, segments
Optional Fields: 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"
    }
]

Note

The system works correctly even if the config and timestamp fields are missing entirely.


Returns

Type: Dict[str, Any]

{
    'total': 3,       # Total number of registration attempts
    'success': 3,     # Number of successful registrations
    'failed': 0,      # Number of failed registrations
    'results': [...]  # Detailed results
}

Validation Errors

Validation errors are raised as a ValueError before the function executes.
failed only includes errors that occur during execution (e.g., network errors, file not found).


Example

Batch Registration for 3 Videos

batch.json file:

[
    {
        "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"}
        ]
    }
]

Batch Registration:

# Batch registration
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']}")

Output:

Total: 3
Success: 3
Failed: 0

results details:
  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