GStreamer clock
The GStreamer clock is the global time reference that the pipeline uses to decide:
WHEN each buffer should be processed, rendered, or sent
Without a clock: - Buffers would flow as fast as possible - Video would play too fast - Audio/video would drift - Network streams would burst
The clock allows: - Real-time playback - Audio ↔ video sync - Smooth network pacing
Demo: play mp4 file
Change autovideosink sync
- True (default) use clock to play the video
- False: play the video as fast as possible
Clock + timestamps (critical pair)
Every buffer may carry a timestamp:
- PTS – when to present
- DTS – when to decode
The sink compares: buffer PTS vs pipeline clock time
Decision:
- PTS > now → wait
- PTS ≈ now → render/send
- PTS < now → late (drop or rush)
This is why sync=true matters.
Clock source
Only one element provides the clock.
Clock provider priority: - Audio sink (most stable) - Live source (camera, mic, RTP) - System clock (fallback)
Clock in different pipeline types
File playback
- No audio → system clock
- With audio → audio sink clock
Demo
Camera
- Camera provides clock
- No preroll
RTP / UDP streaming
Sender
- Sender timestamps buffers
- Sink uses clock to pace packets
Receiver
- rtpjitterbuffer re-aligns timestamps
- Sink syncs to clock
Live vs non-live sources (very important)
| Source | is-live | Clock behavior |
|---|---|---|
| filesrc | false | preroll, seekable |
| v4l2src | true | no preroll |
| udpsrc | true | real-time |
| appsrc (live) | true | you control time |
preroll
Preroll is the process where a pipeline buffers just enough data so that playback can start smoothly at time 0.