Transcribing and subtitling a video

With 'click to listen' videos become increasingly popular and more viewers watching without sound, subtitles have never been more important. Our API can transcribe and subtitle video automatically.

Transcribing

First we need to create the transcription.

To transcribe a video, you need to create an asset (check out our creating an asset guide for more info on how to do this). As you are creating the asset, you will need to pass the transcribe: true option as a body parameter (more detail here, under 'Transcribing').

Subtitling

Once you have your asset uploaded and processed (with the transcription), we can start constructing the render object request for the subtitles.

First we need to add the asset as a video element:

{
"elements": [
{
"type": "video",
"params": {
"source": {
"asset_id": "28a510a8-6690-4cdc-b319-e0e02ebf1a2e"
},
}
}
]
}

Next step is to create a subtitle element, making sure it references the correct asset_id:

{
"elements": [
{
"type": "video",
"params": {
"source": {
"asset_id": "28a510a8-6690-4cdc-b319-e0e02ebf1a2e"
},
}
},
{
"type": "subtitles",
"params": {
"source": {
"asset_id": "28a510a8-6690-4cdc-b319-e0e02ebf1a2e"
},
}
}
]
}

Now you are ready to send the request. Save the above as a render.json file, and run this command:

REQUEST
-X POST \
--header "Authorization: veed_test_oEnZhnd3vg0LEoTs6Z9Ij" \
--data @render.json \
https://api.veed.dev/render

Make sure to use your own API key. You should get a response that looks like this:

RESPONSE
{
"id": "b477e483-592a-4bc6-a22b-563ef7f48e25",
}

Getting the result

We recommend using a Webhook to process all your rendering events, but for this example we'll be polling the API (you can find more info on polling the API here, under 'Obtaining the finished render'):

REQUEST
curl \
--header "Authorization: veed_test_oEnZhnd3vg0LEoTs6Z9Ij" \
https://api.veed.dev/render/b477e483-592a-4bc6-a22b-563ef7f48e25

You should get a SUCCESS response, once the rendering is done:

RESPONSE
{
"type": "RENDER_SUCCESS",
"payload": {
"id": "b477e483-592a-4bc6-a22b-563ef7f48e25",
"progress": 100,
"url": "https://cdn.veed.dev/R1vqZ0KfPp5y2z7ddiTyt.mp4"
}
}

You can use the url in the response to download the render and enjoy your new video, with hardcoded subtitles!