Stream/Encode videos using Azure Media Services and Node Js
I have an application that uses AWS Elastic Transcoder to encode videos uploaded to S3 buckets into HLS streaming formats using Lambda functions :
var AWS = require('aws-sdk');
var eltr = new AWS.ElasticTranscoder({ apiVersion: '2012–09–25', region: 'ap-south-1' });
exports.handler = function (event, context) {
var key = event.Records[0].s3.object.key;
let srcKey = decodeURIComponent(key.replace(/\+/g, " ")); //the object may have spaces
let newKey = key.split('.')[0].replace('protected-video-input/', '')
eltr.createJob({
PipelineId: pipelineId,
OutputKeyPrefix: 'protected-video-output/' + newKey + '/',
Input: {
Key: srcKey,
FrameRate: 'auto',
Resolution: 'auto',
AspectRatio: 'auto',
Interlaced: 'auto',
Container: 'auto'
},
Outputs: [
{
Key: newKey + '_64k_audio',
PresetId: '1351620000001-200071',
SegmentDuration: "10"
},
{
Key: newKey + '_360',
PresetId: '1593703351160-e26c00',
SegmentDuration: "10"
},
{
Key: newKey + '_480',
PresetId: '1593703253941-idqn5g',
SegmentDuration: "10"
},
{
Key: newKey + '_720',
PresetId: '1593702727032-5klbqi',
SegmentDuration: "10"
},
{
Key: newKey + '_1080',
PresetId: '1593702631383-73kckt',
SegmentDuration: "10"
},
{
Key: newKey + '.mp4',
PresetId: '1351620000001-000020'
},
],
Playlists: [
{
Format: 'HLSv3',
Name: newKey,
OutputKeys: [
newKey + '_64k_audio',
newKey + '_360',
newKey + '_480',
newKey + '_720',
newKey + '_1080'
]
}
]
});
};
- This lambda function converts the videos uploaded to the S3 bucket (now replaced with Azure Blob Storage) into streaming formats (HLS / .m3u8) with different video quality levels (380p, 480p, 720p, 1080p).
- Currently, I am tasked with migrating all resources used in this application from AWS to Azure, and I am a novice with Azure Services.
- From my research, I have identified Azure Media Services as an alternative to AWS Elastic Media Encoder.
I replaced the S3 bucket with Azure Blob Storage in order to upload my video files.
Please help with ANY of the following :
- Any examples of which method/function of Azure Media Services should I use for converting to HLS format in node js?
- Should the videos be stored in Blob Storage or Media Services Assets?
Comments
Post a Comment