awscdk-construct-live-channel-from-mp4-file
CDK Construct for setting up a simple live channel for testing
- The input is MP4 files with loop playback
- The output is a live channel with:
- a MediaLive channel with 29.97fps, 3x bitrates (720p/540p/360p)
- a MediaPackage v1 channel with HLS/DASH/MSS/CMAF endpoints
- You can add timecode overay with a prefix for visual confirmation
- You can configure:
- Channel class: STANDARD or SINGLE_PIPELINE
- GOP length
- Segment length
- Manifest length
Install
Usage
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { LiveChannelFromMp4 } from 'awscdk-construct-live-channel-from-mp4-file';
export class ExampleStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const { eml, empv1, empv2 } = new LiveChannelFromMp4(this, 'LiveChannelFromMp4', {
sourceUrl: 'https://example.com/test.mp4',
channelClass: 'STANDARD',
gopLengthInSeconds: 2,
segmentDurationSeconds: 4,
manifestWindowSeconds: 20,
timecodeBurninPrefix: 'Ch1',
hlsAdMarkers: 'SCTE_ENHANCED',
autoStart: true,
startoverWindowSeconds: 1209600,
separateAudioRendition: true,
mediaPackageV2ChannelGroupName: 'my-first-channel-group',
mediaPackageVersionSpec: 'V1_ONLY',
});
new cdk.CfnOutput(this, "MediaLiveChannelId", {
value: eml.channel.ref,
exportName: cdk.Aws.STACK_NAME + "MediaLiveChannelId",
description: "MediaLive channel ID",
});
if (empv1) {
new cdk.CfnOutput(this, "MediaPackageV1HlsEndpoint", {
value: empv1.endpoints.hls.attrUrl,
exportName: cdk.Aws.STACK_NAME + "MediaPackageV1HlsEndpoint",
description: "MediaPackage V1 HLS endpoint URL",
});
}
if (empv2) {
const {hls, llHls} = empv2.endpointUrls;
new cdk.CfnOutput(this, "MediaPackageV2HlsEndpoint", {
value: hls,
exportName: cdk.Aws.STACK_NAME + "MediaPackageV2HlsEndpoint",
description: "MediaPackage V2 HLS endpoint URL",
});
new cdk.CfnOutput(this, "MediaPackageV2LlHlsEndpoint", {
value: llHls,
exportName: cdk.Aws.STACK_NAME + "MediaPackageV2LlHlsEndpoint",
description: "MediaPackage V2 LL-HLS endpoint URL",
});
}
}
}