Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: MIT-0
This solution will deploy a pre-configured EC2 instance, optional networking, and an IVS channel, all with CloudFormation. When you push an RTMP feed to the EC2 instance, it will automatically inject subtitles and start the live IVS channel with captions.
This project is meant as a demonstrator for how to generate real-time subtitles using Amazon Transcribe.
The CloudFormation template will deploy all the resources above, into a subnet of your choosing, or create a new VPC+Subnets from scratch.
Deploy cloudformation.yaml into your AWS Account by uploading the template. Only one CloudFormation parameter, SourceVideoCIDR is required.
Parameter Name | Description |
---|---|
IVSChannelName | Name of the new IVS Channel to create |
LatestImageId | Ubuntu Linux Image Id. Leave blank for default, which is ami-0557a15b87f6559cf |
EC2KeyPairName | Name of existing EC2 Keypair. If you leave this blank, you will only have SSH access via the management console. |
ExistingSubnetId | ID of an existing subnet. If you leave this blank, a new VPC and subnet will be created. |
ExistingSecurityGroupId | ID if an existing security group. If you leave this blank, a new security group will be created. |
SourceVideoCIDR (Required) | CIDR block or ip for source video, used for a new EC2 security group only. (ex. x.x.x.x/32 for single IP) |
In the CloudFormation outputs, there is an RTMPEndpoint
that you can use to publish RTMP video to using a tool such as OBS.
If you entered a SourceVideoCIDR
, that CIDR range will be open on the security group on port 22 and 1935 so that you may SSH and also RTMP push video to the EC2 instance.
When a video publish begins, the Nginx RTMP module will execute a shell script that has been pre-installed on the EC2 instance. This script kicks off a video production workflow to inject subtitles, using ffmpeg, NodeJS, and a modified version of libcaption that is hosted in this repo.
After the workflow starts, the video with subtitles is pushed to a new Amazon IVS Channel. The link to the channel's m3u8 URL is inside the CloudFormation outputs, called ChannelPlaybackUrl
.
Congrats! You now have an IVS channel with subtitles!
Stop reading here, unlses you want to customize and run this manually.
You can also clone this repo and build the source code into any Linux system. The instructions are below. You can also find the full script of commands inside the cloudformation.yaml.
This project requires nodejs 16+ and cmake build tools.
npm install
to install dependencies.There is a bash script start.sh
to start up all the components. The 4 parameters are:
-i input_url
, input/source 1 stream url-b input_url
, input/source 2 stream url (may be same as input 1, or different)-d destination_url
, the output/destination stream url-f format
, the output/destination format. If RTMP, then use flv-d delay
, the delay to add to the video to sync up the subtitleschmod +x start.sh
./start.sh -i rtmps://input-url/live/1234 -b rtmps://input-url/live/1234 -o rtmps://output-url/live/1234 -f flv -d 1.5