Cloud Native 16 min read

Build Elastic, Low‑Cost Serverless Video Processing on Alibaba Cloud

This article explains how to design and implement an elastic, high‑availability video‑on‑demand solution on Alibaba Cloud using Function Compute and Function Flow, covering simple and full‑featured architectures, performance and cost comparisons, and practical deployment steps.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
Build Elastic, Low‑Cost Serverless Video Processing on Alibaba Cloud

Background

Video‑on‑demand services need scalable video transcoding. Using Alibaba Cloud serverless products Function Compute and Function Flow removes hardware procurement and infrastructure management.

Why Serverless?

Serverless provides elastic scaling, built‑in monitoring, pay‑as‑you‑go pricing, and tight integration with Object Storage Service (OSS) and CDN, making it suitable for CPU‑intensive FFmpeg transcoding.

Simple video processing system

When a user uploads a video to OSS, an OSS PutObject event triggers a Function Compute instance that runs FFmpeg to transcode the video and writes the output back to OSS.

OSS event triggers automatically invoke the function on a PutObject event.

Because Function Compute has a default 10‑minute execution limit, large or batch jobs may exceed this limit. Two mitigation strategies are recommended:

Split the source video into time‑based fragments (see the fc-fnf-video-processing repository) and process each fragment in a separate function.

Request a higher memory allocation (up to 12 GB) and a longer execution timeout from the Function Compute team.

Full‑featured video processing system (example)

The advanced architecture uses Function Flow to orchestrate multiple functions in parallel:

Extract audio while simultaneously transcoding the video to AVI, MP4, and FLV formats.

Apply watermarks, generate GIF previews, and write metadata to a database.

For files larger than 3 GB, slice the video into short segments, process each segment in parallel, and recombine the results.

Video slicing divides a stream into time‑based fragments and creates an index file for later recombination.

Performance and cost comparison

A 4K, 89‑second MOV file requires 188 seconds to transcode on a traditional ECS‑based solution (baseline T). Using Function Compute with appropriate slice lengths reduces the total processing time; the acceleration percentage is calculated as T / FC_transcode_time.

Cost analysis (3 CU, 3 GB memory) shows a monthly expense of ¥246.27 for Function Compute, comparable to an ECS C5 instance (¥219) but with higher utilization and elasticity. In typical workloads the pay‑per‑use model can achieve >80 % cost reduction compared with third‑party video processing services.

Cost reduction % = (Third‑party cost – FC cost) / Third‑party cost

Deployment steps

Create a Function Compute service and upload a handler that invokes FFmpeg.

Configure an OSS event trigger for object uploads (PutObject).

Define a Function Flow workflow that chains functions for slicing, transcoding, watermarking, and post‑processing (e.g., metadata storage, CDN pre‑warm).

Optionally mount a NAS file system to allow functions to read source files directly without copying them to OSS.

All example projects include a README with the exact CLI commands for creating services, uploading code, and publishing the workflow.

Technical Q&A

Can an existing FFmpeg service on VMs/containers be made more elastic? Yes. The same FFmpeg command line can be moved to a Function Compute handler; the function inherits automatic scaling and high availability.

Is a custom service cheaper for lightweight tasks such as generating a GIF from the first few frames? Function Compute charges only for actual execution time, so lightweight FFmpeg jobs are cost‑effective.

How to record transcoding details to a database or pre‑warm a CDN? Add a post‑processing function in the workflow that writes metadata to a database and invokes the CDN pre‑warm API.

How does the system handle concurrent video uploads? Each OSS upload triggers an independent function instance; Function Compute scales out automatically, enabling parallel processing of multiple files.

How to process dozens of 4 GB videos within a few hours? Use video slicing to create many short fragments, then run each fragment in a separate function instance. Parallel execution dramatically reduces overall turnaround time.

Can new processing steps be added without downtime? Update the Function Flow definition and deploy a new version of the affected function. Function Compute supports versioning and aliasing, allowing zero‑downtime rollouts.

Can the system read source files directly from NAS or ECS disks? Function Compute can mount a NAS file system, enabling direct access to files without copying them to OSS.

Reference repositories

fc-fnf-video-processing

– example that demonstrates video slicing, parallel transcoding, and workflow orchestration.

Simple video processing example – contains a minimal FFmpeg handler and OSS trigger configuration.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ServerlessCost Optimizationelastic scalingFunction ComputeVideo TranscodingFunction Flow
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.