Logo

dev-resources.site

for different kinds of informations.

Adding Closed Captions to an Amazon IVS Live Stream

Published at
4/14/2023
Categories
aws
amazonivs
a11y
livestreaming
Author
recursivecodes
Categories
4 categories in total
aws
open
amazonivs
open
a11y
open
livestreaming
open
Author
14 person written this
recursivecodes
open
Adding Closed Captions to an Amazon IVS Live Stream

There are two types of people in this world: those who watch TV shows with captions on, and those who are weird. All joking aside, the importance of closed captions for video cannot be understated. In addition to being crucial for the deaf and hard-of-hearing, captions also are important when audio is unavailable or not clearly audible. Maybe you're watching a video in a public place and the audio is drowned out by ambient noise. Or maybe the person speaking in the video is using a microphone that isn't the best quality, or speaks with an accent or dialect that is unfamiliar to the viewer. Captions are always a good thing. Unfortunately, captioning audio in a live stream is tricky.

Before we dig into the problem of captioning live streams, let's talk about semantics a bit. Did you know that there is a difference between the terms closed caption and subtitle? The HTML spec describes subtitles as:

transcription or translation of the dialogue, suitable for when the sound is available but not understood (e.g. because the user does not understand the language of the media resource's audio track). Overlaid on the video.

The spec describes captions as:

Transcription or translation of the dialogue, sound effects, relevant musical cues, and other relevant audio information, suitable for when sound is unavailable or not clearly audible (e.g. because it is muted, drowned-out by ambient noise, or because the user is deaf). Overlaid on the video; labeled as appropriate for the hard-of-hearing.

This means that when we talk about "closed captions" for live videos, we're usually referring to subtitles since captions usually include descriptive information. Think about a scene in a TV show where an actor gets in the car to leave home and says goodbye to their spouse. The caption for this scene might read "Goodbye, dear. [car engine starts]." We're not close to having AI systems describe contextual information like this for us, so we're limited to adding pure "speech-to-text" subtitles captions to our live stream; we can do that using the method below.

Note: You’ll notice that the title and body of this blog post uses the terms ‘captions’ or ‘closed captions’ even though what we’re really talking about here are subtitles based on the definitions above. Unfortunately, since the term ‘closed captions’ is so commonly misused, it makes the most sense to use this term improperly to help developers find this blog post and learn how to add this feature to their live streams. Just know that what we’re really talking about here are subtitles!

Adding Captions to Amazon IVS Live Streams

The solution that we look at in this post focuses on broadcasting to an Amazon Interactive Video Service (Amazon IVS) live stream from OBS Studio. OBS doesn't offer native support for captioning, but there are several plugins that can perform the necessary speech-to-text conversion and publish the captions to an RTMP stream in the CEA-708/EIA-608 format supported by Amazon IVS. For this demo, I've chosen to use the OBS-captions-plugin by ratwithacompiler (GitHub and plugin page). To get started with this plugin, download it and install it. Once you've got it installed in OBS, select Docks and make sure the Captions dock is enabled.

OBS docks menu

Next, select the 'gear' icon in the Captions dock to modify the settings.

captions dock

Make sure that a Caption Source is selected, and modify the plugin configuration to suit your needs. For example, the default Caption Timeout for me was set to 15.0 seconds, but I found 5.0 seconds to be a better value.

caption plugin configuration

Once you've saved your configuration and started a new live stream, the plugin handles converting your speech to text and produce the required caption information to the live stream.

To play back the caption data with the Amazon IVS player, we can add an event listener to listen for the TextCue event (docs).



ivsPlayer.addEventListener(IVSPlayer.PlayerEventType.TEXT_CUE, (evt) => {
  console.log(evt);
}


Enter fullscreen mode Exit fullscreen mode

The handler as configured above logs all incoming TextCue events to the console.

text cue events logged to console

The text property of the TextCue event contains the caption data.

text cue event details

With some HTML and CSS, we can render the caption data as an overlay on the <video> element. This implementation is highly dependent on your needs, but you should take into account auto-hiding the overlay after a specified period of no caption data.

Summary

In this post, we looked at how to use an OBS plugin to convert speech to text and publish that text as caption data on an Amazon IVS live stream.

livestreaming Article's
30 articles in total
Favicon
"Stream Seamlessly on Your Smart TV with Full Compatibility!"
Favicon
OkeStream Guide: Your Ultimate Companion for Today’s Football Action
Favicon
Adding Real-Time Interactivity to Your Live Streams With AWS AppSync
Favicon
How to Build a Live Video Call Streaming API With EnableX
Favicon
White Label Live Streaming Platform: Build Your Own Custom Solution with Mogi I/O
Favicon
Live Streaming vs. Video On Demand: Decoding the Differences
Favicon
Generating Amazon IVS Stage Tokens for OBS via a Custom Dock
Favicon
Review: Fifine Ampligame AM6 Condenser Mic
Favicon
The Video Streaming Industry In 2024
Favicon
Coolcam Screen Recording: A Week-Long Experience and Comparison
Favicon
The 7 Best Live Streaming SDKs & APIs
Favicon
OBS에서 WHIP을 사용하여 Amazon IVS 실시간 스트림으로 브로드캐스팅하기 (Broadcasting to an Amazon IVS Real-Time Stream with WHIP from OBS)
Favicon
How to Enhance Live Streaming Quality in 8 Steps
Favicon
Amazon IVS Live Stream Playback with Chat Replay using the Sync Time API
Favicon
Broadcasting to an Amazon IVS Real-Time Stream with WHIP from OBS
Favicon
RestAPI vs WebSocket Guide
Favicon
Top 6 Live Streaming Platforms in 2024
Favicon
Join us today for the Real-Time Streaming Hackathon Pre-Event! 🌐✨
Favicon
How to Create Your Own Streaming Service on AWS in 5 minutes?
Favicon
What is the best way to stream 360 videos?
Favicon
How To Start Your Own IPTV Service
Favicon
How we lowered the bitrate for live and VOD streaming by 32.5% without sacrificing quality
Favicon
Creating a Dynamic Layout for Multi Host Broadcasts with Amazon IVS
Favicon
Understanding White Label Streaming Platforms: The Advantages and Disadvantages
Favicon
Live Streaming With Multiple Hosts via a Browser With Amazon IVS
Favicon
Creating a Real Time Multi Host Video Chat in a Browser with Amazon IVS
Favicon
Mastering the Art of Live Streaming with ZEGOClOUD SDK and Flutter
Favicon
Build a custom live streaming engine with Ant Media Server plugins
Favicon
How to Create a Live Streaming App
Favicon
Adding Closed Captions to an Amazon IVS Live Stream

Featured ones: