Skip to main content

Use cases and limitations

Serverless code functions definitely can have a place in video transcoding, but because of the much heavier processing it demands, the use cases are very different.

Use cases

Transcoding short videos to small resolutions (<1min @ 480p, or shorter)

If you need to transcode fairly short videos to small sizes, serverless code functions can do the job. You need to consider how important the video quality and filesize are to your use case, as transcoding videos using the x265 codec takes a much longer time than using the x264 codec.

For reference, I tested transcoding a 58 second video to 480p, and it took AWS Lambda 144 seconds to transcode it with x265 using the medium preset, and 9.7 seconds with x264 using the ultrafast preset. It's a huge difference in both time and cost, if the filesize is not important to you.

Limitations

Computation power limits

Transcoding videos is an extremely computation-heavy task. Compared to images, where your serverless code might take at most a few seconds to finish even for large resizes, transcoding videos - even small ones - can take minutes for a serverless code function with some codecs!

This presents a problem: if you want to transcode a long video, for example a 10-minute video, you will almost certainly reach the maximum execution duration allowed by your cloud function provider. AWS Lambda has a maximum execution time of 15 minutes per function invocation: anything that takes longer than this will be forcibly terminated.

If you're using x265/HEVC as your video codec, anything other than very short videos being resized to more than 480p will cause your cloud function to time out in most cases - it is too heavy a task for your cloud function to perform. On top of that, waiting several minutes isn't something most users will like, which limits the use case for this somewhat.