Import a YouTube video and dub it
This is the shortest path from a YouTube URL to a dubbed language. You will:
- Create a video
- Poll the import job
- Start a
plusdub
Prerequisites
Section titled “Prerequisites”- A scoped API key (
videos:write,jobs:read,dubs:write) - Enough credits for a Plus dub of the video’s duration
export BRAIV_API_BASE=https://api.braiv.co/v1export BRAIV_API_KEY=braiv_live_...1. Import
Section titled “1. Import”VIDEO=$(curl -sS -X POST "$BRAIV_API_BASE/videos" \ -H "Authorization: Bearer $BRAIV_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{"source":{"type":"youtube","url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ"}}')VIDEO_ID=$(echo "$VIDEO" | jq -r .videoId)JOB_ID="import_$VIDEO_ID"The response includes videoId and an import_* job.
2. Wait for import
Section titled “2. Wait for import”for i in $(seq 1 60); do STATUS=$(curl -sS "$BRAIV_API_BASE/jobs/$JOB_ID" \ -H "Authorization: Bearer $BRAIV_API_KEY" | jq -r .status) if [ "$STATUS" = "ready" ] || [ "$STATUS" = "failed" ]; then break; fi sleep 10done3. Create a dub
Section titled “3. Create a dub”curl -sS -X POST "$BRAIV_API_BASE/videos/$VIDEO_ID/dubs" \ -H "Authorization: Bearer $BRAIV_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{"languages":["es"],"product":"plus"}'Poll dub_{videoId}_es_plus the same way. When GET /videos/{videoId}/dubs/es?product=plus returns completion: full_ready, you can download a language MP4.
What’s next
Section titled “What’s next”- Dub products —
plusvspremium - Credits — quote before you spend
- Webhooks — skip polling