Introducing Closed Captions for MP4 and HLS
Bruno Celeste (@brunoceleste)
March 25, 2014 Features
We are happy to announce the support of closed captions for MP4 and HLS formats. We currently support SRT and WebVTT as input format.
MP4 Closed Captions
If the output is an MP4 file, the captions will use the mov_text
codec with fourcc tx3g
, so it's compatible with everything from quicktime to iOS and more.
Captions for HTTP Live Streaming format
With the HLS format, it's a different work as we need to segmentize the caption files first and then generate the associated playlist in m3u8. If the input captions are SRT files, we will automatically convert them into proper WebVTT files.
The file structure stays very simple, the playlist and webvtt files will be uploaded to the same directory than the other video segments and playlists.
The naming convention is caption-$lang.m3u8
for the playlist and caption-$lang-$num.webvtt
for the caption segment files:
caption-en.m3u8
caption-en-00000.webvtt
caption-en-00001.webvtt
caption-en-00002.webvtt
caption-en-00003.webvtt
...
caption-es.m3u8
caption-es-00000.webvtt
caption-es-00001.webvtt
caption-es-00002.webvtt
caption-es-00003.webvtt
...
Using the API
As usual, the API is very simple: you give one or more caption URLs (caption_urls
), languages (caption_languages
) and names (caption_names
) separated by comma, and you are done. Here is an example:
The config file captions.conf
:
[post:hls/job]
video_id = 1234,
format_ids = HLS_360p_600K,HLS_360p_1000K,HLS_720p_1500K
output_url = s3://a:s@bucket/hls
caption_urls = http://mysite.com/sub/abc/en.srt,http://mysite.com/sub/abc/es.srt
caption_languages = en,es
caption_names = English,Español
[robot:ping]
url = http://mysite.com/ping
Create the job in ruby:
hw = Coconut.new("HW-API-Key", "k-api-key")
ini = File.read("captions.conf")
hw.create("robot/job", ini)
Any Comment? Send us a message on Twitter @opencoconut
If you have questions or feedbacks, you can also contact us via our contact page