Design and Practice of a Festival-Themed Video Processing Pipeline

    This article explores the design and implementation of a video processing pipeline tailored for festival-themed content. It addresses core challenges such as bursty traffic, long task chains, and high consistency requirements. By leveraging an event-driven architecture combined with a state machine, developers can transform one-time content production into a repeatable, observable, and rollback-capable engineering pipeline. Key practices in idempotency, storage, distribution, observability, and cost control are also discussed to ensure stability and scalability.

    Design and Practice of a Festival-Themed Video Processing Pipeline

    Festival-themed videos often exhibit distinct peak characteristics: centralized material uploads, short-term surges in processing tasks, fixed release windows, and rapidly rising playback traffic. The launch and rollout process of a festival-themed video can be abstracted as a systematic engineering challenge. For developers, the real task is not just executing a single launch action, but transforming one-time content production behavior into a repeatable, observable, and rollback-capable engineering pipeline. This article provides a general technical practice solution from the perspectives of architecture, process, consistency, reliability, distribution, and cost.

    1. Scenario Characteristics and Core Challenges

    A festival-themed video pipeline typically includes material collection, upload, metadata registration, media processing, content review, multi-bitrate finished product storage, release, playback, and data recycling. Compared to daily content, the challenges of festival scenarios are mainly reflected in four aspects.

    First, bursty traffic is prominent. A large amount of material may be uploaded in a short period, causing the transcoding task queue length to rise rapidly. If the processing system lacks peak-shaving capabilities, both upload success rates and release timeliness will be affected.

    Second, the task chain is long and cross-system. A single upload completion event may trigger multiple sub-tasks such as transcoding, screenshotting, review, indexing, and distribution preheating. Failure in any link can render the finished product unavailable, requiring clear state machines and compensation mechanisms.

    Third, high consistency requirements. The same material may generate duplicate tasks due to retries, repeated callbacks, or manual operations. Without an idempotency key, issues like duplicate transcoding, duplicate billing, and version overwrites can easily occur.

    Fourth, the release window cannot be delayed. Festival content usually has a specific launch time. The system must support canary releases, version rollbacks, and capacity planning to prevent single points of failure from affecting the overall release.

    On Baidu AI Cloud, the above pipeline can be implemented using a combination of general capabilities such as object storage, message queues, container platforms, log services, and monitoring alerts. The design focus is not on a single component, but on the contracts, states, and observability between components.

    2. Overall Architecture: Event-Driven and State Machine

    An “event-driven + state machine” overall architecture is recommended. The upload service publishes an upload completion event after writing the material to object storage; the orchestration service consumes the event and creates processing tasks; media processing capabilities complete transcoding, slicing, and screenshotting; the review service asynchronously provides review conclusions; the release service generates a playable version after passing the review and triggers distribution preheating. Each link is decoupled through message queues, and progress is recorded through a task state table.

    The architecture can be divided into five layers:

    1. Access Layer: Responsible for upload credentials, multipart uploads, metadata registration, and tenant isolation.
    2. Orchestration Layer: Consumes events, creates tasks, drives the state machine, and handles retries and dead letters.
    3. Processing Layer: Executes media processing, review, indexing, and finished product generation, remaining stateless as much as possible.
    4. Storage and Distribution Layer: Object storage preserves source files and finished products, while the Content Delivery Network (CDN) handles playback traffic.
    5. Observability Layer: Log services, monitoring alerts, distributed tracing, and business metric dashboards.

    The state machine should include at least: INIT, UPLOADED, TRANSCODING, REVIEWING, READY, PUBLISHED, FAILED, RETRYING, and ROLLED_BACK. State transitions must be verified by the server and cannot rely solely on client callbacks. Each transition should record the task ID, asset ID, version number, operator, and timestamp for auditing and troubleshooting.

    3. Core Process: From Upload Completion to Playback

    A complete festival-themed video processing flow can be executed in the following steps.

    Step 1: Upload and Registration. The client requests an upload credential, writes the source file to object storage, and submits material metadata, including tenant, content type, festival event ID, expected release window, and review strategy. Upon completion, an event is published carrying the asset ID, version number, and idempotency key.

    Step 2: Task Orchestration. The orchestration service selects a processing template based on the material metadata, such as a festival event multi-bitrate template, a short video rapid template, or a long video template. Before creating a task, it checks if the idempotency key already exists to avoid duplicate creation. Once successfully created, the task enters the transcoding state.

    Step 3: Media Processing. The processing node reads the source file from object storage and generates multi-bitrate finished products, covers, and necessary indexes according to the template. After processing, it writes them back to object storage and publishes a processing completion event. The processing node does not directly modify the release state but only updates the task state, keeping responsibilities single.

    Step 4: Review and Quality Inspection. The review service conducts content review and basic quality checks on the finished product, such as whether the audio and video are complete and the duration meets expectations. Review conclusions are categorized as pass, reject, or manual review. Only tasks that pass or pass manual review can enter the publishable state.

    Step 5: Release and Preheating. The release service generates playback metadata, binds the version number and distribution strategy, and opens playback according to the canary ratio. For popular content, distribution preheating can be triggered in advance to reduce first-frame latency. After release, the previous version’s metadata is retained to support quick rollback.

    Step 6: Recycling and Archiving. Original materials and intermediate files are tiered in storage according to lifecycle policies. Source files not used for a long time are transferred to archive storage, while finished products are retained based on popularity. The retention period for task logs and metrics should meet auditing and troubleshooting needs.

    4. Key Design: Idempotency, Retry, and Dead Letter Queue

    One of the most critical designs in a long-chain system is idempotency. It is recommended to define a stable idempotency key for each processing action, such as “Asset ID + Processing Template + Version Number”. Task creation, event consumption, callback processing, and release actions should all be deduplicated based on this key. Idempotency can be implemented using a deduplication table or conditional state machine updates: only execute if the current state allows transition; otherwise, directly return the already-processed result.

    Retries must distinguish between retryable and non-retryable errors. Network jitter, downstream rate limiting, and temporary unavailability can enter exponential backoff retries; source file corruption, missing templates, and review rejections are non-retryable errors and should directly enter the failed or manual processing queue. Retry counts and backoff limits should be configurable to prevent failed tasks from occupying resources indefinitely.

    The Dead Letter Queue (DLQ) is used to catch tasks that still fail after multiple retries. Dead letter tasks must contain the original event, failure reason, latest error code, and processing trace, and support manual re-delivery. When re-delivering, the original idempotency key is still used to ensure no duplicate finished products are generated.

    Below is an abstract pseudo-code example, independent of specific tools:

    1. function on_upload_completed(event):
    2. key = event.asset_id + ":" + event.profile + ":" + event.version
    3. if not dedup.try_acquire(key):
    4. return "duplicate_ignored"
    5. task = state_machine.create_if_absent(key, INIT)
    6. if task.state != INIT and task.state != FAILED:
    7. return "already_processing"
    8. state_machine.transition(task, UPLOADED)
    9. queue.publish("media_transcode", {
    10. "task_id": task.id,
    11. "asset_id": event.asset_id,
    12. "profile": event.profile,
    13. "version": event.version,
    14. "idempotency_key": key
    15. })
    16. return "accepted"

    The processing completion callback also requires idempotency:

    1. function on_transcode_completed(message):
    2. task = state_machine.get(message.task_id)
    3. if task.state in [READY, PUBLISHED]:
    4. return "late_callback_ignored"
    5. if task.idempotency_key != message.idempotency_key:
    6. return "key_mismatch"
    7. state_machine.transition(task, REVIEWING)
    8. queue.publish("content_review", build_review_message(task))

    5. Storage, Distribution, and Playback Experience

    Source files, intermediate files, and finished products are recommended to be uniformly managed using object storage, with a metadata table maintaining the relationship between materials and objects. Buckets or directories should be isolated by tenant and event, and access control should follow the principle of least privilege. Playback addresses should use short-term signed access to avoid long-term public links.

    On the distribution side, attention should be paid to cache key design. The cache key should at least include the finished product version number. When releasing a new version, a new cache key is generated to prevent old version cache pollution. During a canary release, different proportions of users may hit different versions, and the release service needs to explicitly define the version mapping in the playback metadata. When rolling back, only the version mapping needs to be switched without deleting the finished products.

    Playback experience metrics include time to first frame, stall rate, playback error rate, and cache hit rate. For festival trending content, edge caches can be preheated in advance; for long-tail content, origin pulls are on-demand. Distribution strategies should support observing quality differences by region, ISP, and terminal type, but specific performance data should not be promised without verification.

    6. Observability and Capacity Planning

    Observability should cover three levels: logs, metrics, and tracing. Logs should uniformly carry the asset ID, task ID, tenant ID, and trace ID. Metrics should at least include upload success rate, task queue duration, transcoding failure rate, review duration, release success rate, playback error rate, and cache hit rate. Tracing is used to connect the critical path of a material from upload to release.

    Alerts should be tiered: drops in upload success rate, abnormal task queue durations, sudden spikes in dead letters, and increased release failure rates are high priority; storage capacity levels and drops in cache hit rates are medium priority. Alert information should be accompanied by affected tenants, event IDs, and recent error summaries, avoiding overly generic thresholds.

    Regarding capacity planning, peaks in material uploads, processing concurrency, and playback should be evaluated before the festival. The processing layer scales elastically through a container platform, while message queues are used for peak shaving; storage and distribution reserve capacity based on event popularity. Drills should be conducted before the release window to verify rollback, dead letter re-delivery, and canary switching processes.

    7. Cost Control and Release Governance

    Cost control is not simply about reducing specifications, but tiering based on content value. Original materials enter low-frequency or archive storage after processing is complete; intermediate files are set with shorter lifecycles; finished products retain multi-bitrate versions based on popularity, and long-tail content may only retain necessary bitrates. Media processing templates are selected based on the scenario to avoid using the same high-spec template for all content.

    For release governance, it is recommended to establish an event-level release ticket recording the release scope, canary ratio, review conclusions, rollback version, and responsible person. Canary releases can gradually increase volume by tenant, region, or user ratio, and full release proceeds after observing playback error rates and distribution quality. Any automated release should retain a manual pause entry point.

    8. Conclusion

    The launch of a festival-themed video should not merely be a manual operation, but should precipitate into an event-driven, state-trackable, and failure-compensable pipeline. By using idempotency keys and state machines to ensure consistency, message queues and dead letter queues to improve reliability, object storage and distribution strategies to optimize playback experience, and log services and monitoring alerts to shorten troubleshooting time, combined with canary releases and cost tiering, developers can build a stable, scalable, and auditable festival-themed video processing system.