LiveKit 推出 Video Frame Metadata 影片影格中繼資料功能
Introducing video frame metadata
LiveKit 宣佈支援 Video Frame Metadata,讓每個已擷取的影片或二進制資料影格可附加以微秒為單位的用戶時間戳、順序影格 ID 及自訂資料。功能現已提供於 Rust、Python、C++ 和 JavaScript SDK,音訊影格支援則將於未來版本加入。SFU 會為不支援該功能的下游用戶端移除中繼資料尾段,以維持與現有用戶端 SDK 的相容性。
Timing is everything#
WebRTC uses timestamps to keep audio and video playback smooth, synchronized, and resilient to network issues. But for use cases like robotics, the standard WebRTC RTP timestamps aren't enough for precise timing and alignment across many different sensors. Robotics systems typically depend on a ground-truth clock that the entire system is synchronized to like GPS, PTP, or another high-precision timing signal. RTP timestamps rarely align with this clock. There have been efforts to standardize mechanisms for carrying true device capture time in WebRTC, such as the Absolute Capture Timestamp extension, however as of today it remains in limbo as an expired proposal.
Today, we're announcing support for Video Frame Metadata in LiveKit. When enabled, every captured video or binary data frame (audio frames will be supported in a future version) can now include:
- User Timestamp: your ground-truth sensor timestamp in microseconds
- Frame ID: a sequential ID that allows you to uniquely reference every frame
- User Data: any arbitrary data relevant to the frame
This additional information makes it simple to precisely synchronize several tracks to a single reference clock.
Pinning metadata to individual frames opens up workflows that were not possible before:
- Sensor alignment for robotics: stamp each frame with your system's ground-truth clock so video lines up with LiDAR, IMU, and other sensors, then export every modality with consistent time alignment.
- True glass-to-glass latency: stamp the sensor exposure timestamp from your camera driver on every frame and precisely measure latency across your whole streaming pipeline: capture, encode, network, decode, and render.
- Frame-accurate correlation: carry a sequential
frame_idso downstream consumers can line up video frames with external data such as ML inference output or transcript segments, with no separate channel to keep in sync. - Camera extrinsics and device state: attach additional metadata, such as the joint position of an arm a camera is attached to. This removes the need to buffer and correlate in a post-processing step.
How it works#
Video Frame Metadata allows the developer to attach a timestamp, frame ID, or user data to any captured frame. The protocol is designed to be flexible and allows us to add more fields down the road.
Video Frame Metadata is appended before RTP packetization to each frame as a small binary trailer. It's compatible with all video codecs supported by LiveKit and durable across the transport boundary. Metadata attributes will be emitted on the track subscriber side after the corresponding frame is decoded.
We've also added new signaling to the track publish step so that both the SFU and downstream subscribers know exactly what metadata is available on a given track. LiveKit's SFU will strip trailers for any downstream client that can't parse them, ensuring 100% backwards compatibility with client SDKs that don’t support this feature yet.
Track publication#
When publishing a video track, simply enable the metadata fields you wish to attach to a track.
Frame capture#
Then attach a FrameMetadata object to each frame as you capture it.
On the subscriber side, the published video track advertises its metadata features in TrackInfo. When receiving frames, FrameMetadata is automatically available on every frame.
Try it#
The LiveKit Rust SDK ships a complete, runnable demonstration in the local_video example. The publisher exposes --attach-timestamp, --attach-frame-id, and --attach-user-data to demonstrate how easy it is to attach data, and the subscriber's --display-timestamp renders the frame ID, publisher timestamp, and user data on screen.
Video frame metadata is available now in the Rust, Python, C++, and JavaScript client SDKs. Grab the latest release, run the local_video example, and tell us what you build with it.
來源:LiveKit 產品與工程博客 · livekit.com