Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
awscdk-construct-live-channel-from-mp4-file
Advanced tools
CDK Construct for setting up a simple live channel for testing
CDK Construct for deploying a live video channel using AWS Elemental MediaLive and MediaPackage
Here's an example for setting up a SINGLE_PIPELINE MediaLive channel using a local MP4 file (./upload/test.mp4
) as an input to get MediaPackage v1 and v2 endpoints
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { FilePublisher } from 'awscdk-construct-file-publisher';
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);
// Upload all the files in the local folder (./upload) to S3
const publicFolder = new FilePublisher(this, 'FilePublisher', {
path: './upload',
});
// Create a MediaLive channel with MediaPackage V1/V2 endpoints
const { eml, empv1, empv2 } = new LiveChannelFromMp4(this, 'LiveChannelFromMp4', {
source: `${publicFolder.url}/test.mp4`, // required
channelClass: 'STANDARD', // optional: default = 'SINGLE_PIPELINE'
encoderSpec: {
gopLengthInSeconds: 2, // optional: default = 3
timecodeBurninPrefix: 'Ch1', // optional: default = no timecode overlay
},
mediaPackageVersionSpec: 'V1_AND_V2', // optional: default = 'V1_AND_V2'
packagerSpec: {
segmentDurationSeconds: 4, // optional: default = 6
manifestWindowSeconds: 20, // optional: default = 60
},
autoStart: true, // optional: default = true
});
// Access MediaLive channel attributes via `eml.channel`
new cdk.CfnOutput(this, "MediaLiveChannelId", {
value: eml.channel.ref,
exportName: cdk.Aws.STACK_NAME + "MediaLiveChannelId",
description: "MediaLive channel ID",
});
// Access MediaPackage_v1 endpoints attributes via `empv1.endpoints`
if (empv1?.endpoints) {
new cdk.CfnOutput(this, "MediaPackageV1HlsEndpoint", {
value: empv1.endpoints.hls.attrUrl,
exportName: cdk.Aws.STACK_NAME + "MediaPackageV1HlsEndpoint",
description: "MediaPackage V1 HLS endpoint URL",
});
new cdk.CfnOutput(this, "MediaPackageV1DashEndpoint", {
value: empv1.endpoints.dash.attrUrl,
exportName: cdk.Aws.STACK_NAME + "MediaPackageV1DashEndpoint",
description: "MediaPackage V1 DASH endpoint URL",
});
new cdk.CfnOutput(this, "MediaPackageV1CmafEndpoint", {
value: empv1.endpoints.cmaf.attrUrl,
exportName: cdk.Aws.STACK_NAME + "MediaPackageV1CmafEndpoint",
description: "MediaPackage V1 CMAF (HLS with fMP4) endpoint URL",
});
new cdk.CfnOutput(this, "MediaPackageV1MssEndpoint", {
value: empv1.endpoints.mss.attrUrl,
exportName: cdk.Aws.STACK_NAME + "MediaPackageV1MssEndpoint",
description: "MediaPackage V1 Microsoft Smooth Streaming endpoint URL",
});
}
// Access MediaPackage_v2 endpoint URLs via `empv2.endpointUrls`
if (empv2?.endpointUrls) {
new cdk.CfnOutput(this, "MediaPackageV2HlsEndpoint", {
value: empv2.endpointUrls.hls,
exportName: cdk.Aws.STACK_NAME + "MediaPackageV2HlsEndpoint",
description: "MediaPackage V2 HLS endpoint URL",
});
new cdk.CfnOutput(this, "MediaPackageV2LlHlsEndpoint", {
value: empv2.endpointUrls.llHls,
exportName: cdk.Aws.STACK_NAME + "MediaPackageV2LlHlsEndpoint",
description: "MediaPackage V2 Low-Latency HLS endpoint URL",
});
new cdk.CfnOutput(this, "MediaPackageV2DashEndpoint", {
value: empv2.endpointUrls.dash,
exportName: cdk.Aws.STACK_NAME + "MediaPackageV2DashEndpoint",
description: "MediaPackage V2 DASH endpoint URL",
});
}
}
}
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { LiveChannelFromMp4 } from 'awscdk-construct-live-channel-from-mp4-file';
import { ScteScheduler } from 'awscdk-construct-scte-scheduler';
export class ExampleStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// Create a MediaLive channel with MediaPackage V1 endpoints
const ch = new LiveChannelFromMp4(this, 'LiveChannelFromMp4', {
source: `s3://my-bucket/test.mp4`,
}), {eml, empv1: emp} = ch;
// Harvest the HLS endpoint
if (emp?.endpoints.hls) {
// Get a Lambda function that schedules a harvest job
const harvestJob = ch.createHarvestJob({
endpoint: emp.endpoints.hls,
publish: true,
retain: true,
});
// Invoke the function after inserting a 30-sec ad break x50 times
new ScteScheduler(this, 'ScteScheduler', {
channelId: eml.channel.ref,
scteDurationInSeconds: 30,
intervalInMinutes: 1,
repeatCount: 50,
callback: harvestJob.func,
});
// Print the URL of the harvested VOD content
new cdk.CfnOutput(this, "HarvestedVODURL", {
value: harvestJob.publishedUrl,
exportName: cdk.Aws.STACK_NAME + "HarvestedVODURL",
description: "Harvested VOD URL",
});
}
}
}
The input needs to be a single or multiple MP4 file(s). The following formats are supported:
FilePublisher
like the above code)http://
and https://
)s3://
and s3ssl://
)Also, you can convert File inputs into Push inputs before they're ingested by MediaPackage The following code creates 3x inputs with different routes:
// Create a live channel with 3x inputs
const {eml, empv1, empv2} = new LiveChannelFromMp4(this, 'LiveChannelFromMp4', {
source: [
{
url: 's3://aems-input/test-1.mp4',
conversionType: 'NONE', // default
},
{
url: 's3://aems-input/test-2.mp4',
conversionType: 'RTP_PUSH',
},
{
url: 's3://aems-input/test-3.mp4',
conversionType: 'RTMP_PUSH',
},
],
autoStart: true,
});
By default, all possible endpoints will be created for each version of MediaPackage:
You can specify only necessary MediaPackage version:
// Create a live channel with all MediaPackageV2 endpoints but LL-HLS
const {eml, empv2} = new LiveChannelFromMp4(this, 'LiveChannelFromMp4', {
source: 's3://aems-input/test-1.mp4',
mediaPackageVersionSpec: 'V2_ONLY', // default = 'V1_AND_V2'
mediaPackageV2Settings: {
omitLlHls: true, // default = false
}
});
By default, the following parameters will be used for encoding and packaging:
You can further configure the encoding/packaging behavior using low-level settings:
// Create a live channel using CfnChannel and CfnOriginEndpoint props
const {eml, empv1, empv2} = new LiveChannelFromMp4(this, 'LiveChannelFromMp4', {
source: 's3://aems-input/test-1.mp4',
encoderSpec: { // CfnChannel.EncoderSettingsProperty
outputGroups, // CfnChannel.OutputGroupProperty[]
videDescriptions, // CfnChannel.VideoDescriptionProperty[]
audioDescriptions, // CfnChannel.AudioDescriptionProperty[]
timecodeConfig, // 'SYSTEMCLOCK' | 'EMBEDDED'
availBlanking, // CfnChannel.AvailBlankingProperty
},
packagerSpec: { // MediaPakcageV1Props
startoverWindowSeconds, // 0 ~ 1209600 (14 days)
endpointSpec, // CfnOriginEndpoint.XxxPackageProperty (Hls/Dash/Cmaf/Mss)
} or { // MediaPakcageV2Props
channelGroupName, // Existing channel group
startoverWindowSeconds, // 0 ~ 1209600 (14 days)
endpointSpec: {
containerType, // 'TS' | 'CMAF'
manifests, // CfnOriginEndpoint.XxxManifestConfigurationProperty[] (Hls/LowLatencyHls/Dash)
segment, // CfnOriginEndpoint.SegmentProperty
}
}
});
FAQs
CDK Construct for setting up a simple live channel for testing
The npm package awscdk-construct-live-channel-from-mp4-file receives a total of 3 weekly downloads. As such, awscdk-construct-live-channel-from-mp4-file popularity was classified as not popular.
We found that awscdk-construct-live-channel-from-mp4-file demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.