-2

I have a S3 bucket with a lot of .mp4 videos inside different folders, I wish to convert them to HLS using AWS media Convert.

I've created a lambda function which gives me list of all the .mp4 videos in that bucket, but that info is not enough for AWS media convert to run and media convert JOB.

What will be the best approach to handle such case? Converting all existing mp4 files in a s3 bucket using media convert.

Amit
  • 187
  • 2
  • 15
  • Did you read the [documentation](https://docs.aws.amazon.com/mediaconvert/latest/ug/what-is.html)? Did you try creating a Media Convert job with or without preset? What problems did you run into? – jarmod Nov 25 '22 at 16:17
  • I already have a media convert job that will convert any incoming .mp4 file to hls outputs, I just want to run batch operations on old .mp4 files of a particular folder in this bucket so that even older mp4 files has an hls output. – Amit Nov 28 '22 at 07:18
  • What problem are you having creating a new job that simply transcodes the known list of MP4 files? – jarmod Nov 28 '22 at 16:55

2 Answers2

0

Yes you can use AWS Elemental MediaConvert to convert media files. You did not mention what Lambda run-time you are using to write the Lambda function. I will assume JavaScript to answer this question.

To use AWS SDK for JavaScript to write a Lambda function that invokes AWS Elemental MediaConvert , use the following code examples as a reference.

Notice that you require a lot of parameters to successfully convert a file using this service.

https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/mediaconvert

Also -- be sure to read the service docs too.

https://docs.aws.amazon.com/mediaconvert/latest/ug/what-is.html

smac2020
  • 9,637
  • 4
  • 24
  • 38
  • Please avoid link-only answers. The question itself is off-topic (just a set of requirements, no programming question, no effort shown) – David Makogon Nov 26 '22 at 16:11
  • Agreed a link only with no context is no good. However my response does confirm that AWS Elemental MediaConvert is the service to use for this use case and the links is where the user can locate further information. These links are to official Amazon docs. – smac2020 Nov 26 '22 at 21:05
  • @DavidMakogon I get your concern but I thought about adding codes but decided against it as it wasn't adding to context of question. I do have lambda function which converts all the incoming files to the bucket Hey smac2020 I'm already using AWS media convert to convert all new incoming files using lamda, This bucket is old and I want to change old .mp4 files as well.. s3 batch operations sounds like an answer https://docs.aws.amazon.com/AmazonS3/latest/userguide/tutorial-s3-batchops-lambda-mediaconvert-video.html Just wanted to know a better solution with just same input/output bucket. – Amit Nov 28 '22 at 07:28
0

You can use the metadata Tags on an existing file to indicate whether it should be re-transcoded. Basically set a 'needs transcoding' flag on all existing files in a batch operation, then transcode the files using a Lambda to call MediaConvert; then update the asset flags upon success message in the MediaConvert logs.

Note: MediaConvert outputs will overwrite existing S3 files of the same name. If you want to preserve filenames then you'll need to copy the old source file to a tmp dir before re-transcoding into the master directory.

aws-robclem
  • 324
  • 2
  • 5