Add Video Captions/Chapters/Subtitles
To update the video thumbnail
Please note that the API URL for video uploads is
upload.dyntube.com
and not api.dyntube.com
.- The file can be added to form input named "file".
- The Content-Type should be multipart/form-data.
post
https://upload.dyntube.com/v1/
videos/captions/{video-id}
To upload a captions/subtitle file
Parameters
Body
file*
File
Form File
kind
String
The value should be subtitles or chapters depending on the use case.
language
String
two-letter language code. i.e. en,fr. The default is 'en'.
label
String
e.g. 'English' or 'French'. The default is English.
For video chapters, the label can be called "Chapters".
default
Boolean
Default captions in the video player. The default is false.
rtl
Boolean
RTL support. The default is false.
Responses
200: OK
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
class Program
{
static void Main(string[] args)
{
string videoId = "your_video_id";
string bearerToken = "your_bearer_token";
string filePath = "path/to/captions.vtt";
string language = "en";
string label = "English";
bool isDefault = true;
bool isRtl = false;
string url = $"https://upload.dyntube.com/v1/videos/captions/{videoId}";
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearerToken);
using (var form = new MultipartFormDataContent())
{
form.Add(new StreamContent(File.OpenRead(filePath)), "file", "captions.vtt");
form.Add(new StringContent(language), "language");
form.Add(new StringContent(label), "label");
form.Add(new StringContent(isDefault.ToString()), "default");
form.Add(new StringContent(isRtl.ToString()), "rtl");
var response = httpClient.PostAsync(url, form).Result;
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
Console.WriteLine("Captions updated successfully.");
}
else
{
Console.WriteLine($"Error updating captions. Status code: {response.StatusCode}");
}
}
}
}
}
const fs = require('fs');
const axios = require('axios');
const videoId = 'your_video_id';
const bearerToken = 'your_bearer_token';
const filePath = 'path/to/captions.vtt';
const language = 'en';
const label = 'English';
const isDefault = true;
const isRtl = false;
const url = `https://upload.dyntube.com/v1/videos/captions/${videoId}`;
const config = {
headers: {
Authorization: `Bearer ${bearerToken}`,
'Content-Type': 'multipart/form-data',
}
};
const formData = new FormData();
formData.append('file', fs.createReadStream(filePath), 'captions.vtt');
formData.append('language', language);
formData.append('label', label);
formData.append('default', isDefault ? 1 : 0);
formData.append('rtl', isRtl ? 1 : 0);
axios.post(url, formData, config)
.then(response => {
if (response.status === 200) {
console.log('Captions updated successfully.');
} else {
console.log(`Error updating captions. Status code: ${response.status}`);
}
})
.catch(error => {
console.log(`Error updating captions. ${error}`);
});
import requests
video_id = 'your_video_id'
bearer_token = 'your_bearer_token'
file_path = 'path/to/captions.vtt'
language = 'en'
label = 'English'
is_default = True
is_rtl = False
url = f'https://upload.dyntube.com/v1/videos/captions/{video_id}'
headers = {
'Authorization': f'Bearer {bearer_token}',
}
files = {
'file': ('captions.vtt', open(file_path, 'rb')),
}
data = {
'language': language,
'label': label,
'default': int(is_default),
'rtl': int(is_rtl),
}
response = requests.post(url, headers=headers, files=files, data=data)
if response.status_code == 200:
print('Captions updated successfully.')
else:
print(f'Error updating captions. Status code: {response.status_code}')
<?php
$videoId = 'your_video_id';
$bearerToken = 'your_bearer_token';
$filePath = 'path/to/captions.vtt';
$language = 'en';
$label = 'English';
$isDefault = true;
$isRtl = false;
$url = "https://upload.dyntube.com/v1/videos/captions/{$videoId}";
$options = array(
'http' => array(
'header' => "Authorization: Bearer {$bearerToken}\r\n",
'method' => 'POST',
'content' => http_build_query(array(
'language' => $language,
'label' => $label,
'default' => $isDefault ? 1 : 0,
'rtl' => $isRtl ? 1 : 0,
)),
'ignore_errors' => true,
),
);
$options['http']['content'] .= "\r\n--" . uniqid() . "\r\n";
$options['http']['content'] .= "Content-Disposition: form-data; name=\"file\"; filename=\"captions.vtt\"\r\n";
$options['http']['content'] .= "Content-Type: text/vtt\r\n\r\n";
$options['http']['content'] .= file_get_contents
Last modified 6mo ago