How Bilibili’s Third‑Gen Streaming Transcoder Cuts Latency with Smart Architecture

This article details Bilibili's third‑generation streaming transcoding system, explaining its architecture, core modules, testing strategies, quality‑assurance plans, and code examples that together dramatically reduce processing time and support millions of daily video uploads.

Bilibili Tech
Bilibili Tech
Bilibili Tech
How Bilibili’s Third‑Gen Streaming Transcoder Cuts Latency with Smart Architecture

Background

Video transcoding is the core of Bilibili's video processing pipeline, providing unified formats for playback compatibility, multiple resolutions for different scenarios, and bandwidth‑cost control through varied encoding algorithms.

Testing Architecture and Quality Assurance Plan

Transcoding Architecture

Streaming transcoding involves many technical modules. After a video enters the system, it passes through business orchestration, standard production, metadata calculation, scheduling service, slicing service, transcoding images, and finally the execution unit, completing a full transcoding round. A simplified framework diagram is used for designing quality‑assurance schemes.

Quality Assurance Plan

The streaming transcoding solution must adapt to multiple pipelines, covering dimensions such as business parameters, codec configurations (CPU, GPU, hardware), and technical attributes (narrow‑band HD, pre‑processing). Four assurance directions are planned: impact and dependency analysis of the transcoding flow, core‑technology profiling of each module, efficient problem localization and debugging methods, and multi‑resource compatibility.

Scheduling Module

Key services include:

bvcflow service – handles business communication and task orchestration, managing the lifecycle of multi‑task transcoding.

hive service – performs resource calculation and task dispatch.

OpenBayes service – a new compute platform that enables finer‑grained resource calls and end‑to‑end distributed computing.

Functional Chain Testing

Basic functional tests cover two main transcoding paths (transcode architecture and xcode architecture) and verify metadata (duration, bitrate, frame rate), playback of branch outputs, and multi‑device playback performance across resolutions and codecs.

Sub‑task node product and metadata assertions.

Independent branch output playback verification.

Production‑environment multi‑device playback verification.

Scheduling Strategy Testing

Strategy tests combine different transcoding business types, using the hive service to simulate various scenarios and comparing OpenBayes against hive for task dispatch latency and retry‑mechanism effectiveness. HDR and Dolby Vision high‑quality clips are also tested for processing time and resource utilization.

Slicing Module

Core components:

Slice Scheduler Service – receives slice requests and assigns tasks.

State Machine – manages asynchronous slice state transitions.

Slice Worker – executes the actual slice computation.

Data Module – persists slice task metadata in a database.

Slicing Scheduler Testing

Tests focus on service communication and initialization under high‑concurrency, slice generation speed (e.g., 2 min vs 6 min per clip), boundary alignment of generated m3u8 files, and coordination efficiency among scheduler, worker, and state machine.

Transcoding Image

Key components:

Transcode Scheduler Service – external communication and task lifecycle orchestration.

Transcode Worker – invokes underlying tools such as FFmpeg, x264/x265.

The image processing follows a unified standard flow, as illustrated below.

Transcode Worker Testing

Tests validate handling of diverse resolutions, color spaces (YUV420, YUV444), watermarks, GOP configurations (open‑GOP, B‑frames), and playback on low‑end devices. They also compare frame‑processing logic, bitrate control, and quality metrics such as PSNR.

# Example code for open‑GOP testing
def open_gop(self, path=""):
    ff = FFmpegExecutor()
    ff.execute([
        "-i", path,
        "-c:v", "libx264",
        "-g", "60",
        "-keyint_min", "60",
        "-x264-params", "open_gop=1:bframes=3",
        "output/open_gop.mp4"
    ], show_progress=True)

Online Quality Observation

After integrating streaming transcoding into Bilibili's pipeline, long‑term monitoring of success rates, failure scenarios, and resource usage is performed to continuously iterate and optimize. Core metrics such as task success ratio, slice service throughput, and resource consumption are tracked to ensure stable operation for the daily million‑scale video submissions.

Conclusion: Bilibili's third‑generation streaming transcoder reduces latency through architectural optimizations (slice reuse, IO reduction). The testing team designed multi‑dimensional assurance for scheduling, slicing, and transcoding modules, covering functional chains, strategy verification, extreme‑scenario robustness, and automated production pipelines, thereby supporting stable, high‑throughput daily uploads.

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.

backend architectureTestingstreamingquality assuranceFFmpegBilibiliVideo Transcoding
Bilibili Tech
Written by

Bilibili Tech

Provides introductions and tutorials on Bilibili-related technologies.

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.