0
votes

I'm using AWS Lambda for converting files from WEBM to MP4

I'm using ffmpeg version 4.3.1-static https://johnvansickle.com/ffmpeg/ (I have done the following tests also with the ffmpeg in serverless AWS ffmpeg layer (that includes de 4.1.3), but results are even worse (about 25% slower)

I'm using Node 10x as container.

WEBM size   Time to convert.  Memory Lambda.  Memory used (as shown in log)

80Mb             ~44s              3008            410
40Mb             ~44s              3008            375

80Mb             ~70s              1024            321
40Mb             ~70s              1024            279

All videos are 80s length. So as far as I can see, it does not matter the size of the WEBM, if the length of the video is the same, it takes the same to convert. So ffmpeg takes more time if the video length is higher, not if the file size is higher ... curious ;-)

But in the other hand, I'm confused with Lambda memory. I know memory and CPU comes together in Lambda ... the more memory you choose, the more CPU is assigned.

But...

  1. Why ffmpeg just take about 300/400Mb if it has more to run ?
  2. How can I tell ffmpeg to use more memory ?
  3. Is there any option to accelerate the process in Lambda ?

Btw, In all tests, all ffmpeg are the same, and

cpu-used paramenter)

  • I added to ffmpeg parameters cpu-used=100, and it does not matter at all if I put cpu-used=5 ... times are the same, so I guess that parameter is useless (i don't know why)

threads parameter)

  • Also I did some tests with "threads" parameters, but it's useless also.

I know it's not a good comparison, but same files takes about 5 seconds to be converted in a simple dedicated server (8 vCores and 8GB RAM in OVH Centos VPS).

Btw, Amazon Elastic Transcoder is not an option: a) it's extremely more expensive b) it has just his profiles to convert, and my ffmpeg commands are very complex (watermarks, effects, etc ...)

1
Are you including the download WEBM from S3 and upload MP4 to S3 times in those totals? What are the actual ffmpeg conversion times with the Lambda RAM sizes? And are you using the same ffmpeg options? - jarmod
upload/download times are not include here ;-) all ffmpeg options for all tests. I don't understand your second question: you can see in the table with 3M and 1M of lambda memory - FlamingMoe
I mean: are you using the same ffmpeg runtime options in both lambda and on VPS? Also, are there any ffmpeg debug/verbose options that can help you understand the performance difference? - jarmod
Both are the same 4.3.1 static build taken from the same site - FlamingMoe
I don't think you're measuring the same thing here. For example, you indicated that ffmpeg in a Lambda layer was 25% slower. The Lambda layer won't make any difference to the runtime - it will only affect the cold start time, before you run ffmpeg. That's why I'm trying to make sure you are comparing like things, so you know where to focus your efforts (on the cold start, on the download from S3, on the deployment package size, on the ffmpeg threading, on the upload to S3, or something else). - jarmod

1 Answers

0
votes

| Why ffmpeg just take about 300/400Mb if it has more to run ?

It doesn’t need any more memory. It only needs to cache frames its working on.

| How can I tell ffmpeg to use more memory ?

You can’t. Ffmpeg automaticity allocates the memory it needs. Using more would just be wasteful, and not speed anything up.

| Is there any option to accelerate the process in Lambda ?

Nothing lambda specific. Just the standard ffmpeg settings.