Main vs Sub Streams for Security Cameras

Preface

In video streaming application development (such as security surveillance, remote conferencing, or IoT projects), camera configurations often involve the Main Stream and Sub Stream. What are the differences between them? Why is a dual-stream setup necessary? How do you choose?

This article analyzes this “royal pair” from a developer’s perspective using technical language, helping you optimize your system design.

I. Core Concepts: A One-Sentence Summary

  • Main Stream: A high-definition, high-quality stream with high resolution and high bitrate, equivalent to a hardcover book; it pursues ultimate image quality and is suitable for critical scenarios.
  • Sub Stream: A smooth, low-resource stream with low resolution and low bitrate, equivalent to a pocket paperback; it pursues low bandwidth and low latency and is suitable for real-time multi-channel previewing.

Essentially, this is an engineering trade-off of trading quality for resources and trading space for time.

II. Technical Parameter Comparison: A Table of Differences

Parameter comparisons are the most intuitive. The following are typical characteristics (specifics vary by device):

Dimension Main Stream Sub Stream
Aliases primary, main, high sub, extra, low
Resolution High (e.g., 1080P, 4K, 8MP) Low (e.g., 720P, 480P, CIF)
Bitrate High (4~8 Mbps or higher) Low (0.2~1 Mbps)
Frame Rate High (25/30 fps, full frame rate) Low (10~15 fps, configurable)
Bandwidth Usage High (significant network pressure) Extremely low (public internet transmission friendly)
Decoding Consumption High (heavy CPU/GPU burden) Low (easy decoding on mobile devices)
Encoding Profile High (e.g., Main/High Profile) Low (e.g., Baseline Profile)

III. The Necessity of Dual Streams: Addressing Pain Points and Solutions

Without a sub-stream, the system would collapse:

  1. Remote Preview Lag: A 4K main stream (8 Mbps) encountering 2 Mbps upstream bandwidth results in transmission failure or explosive latency.
  2. Multi-Channel Preview Crashes: 16 channels of HD streams require 64 Mbps bandwidth + high decoding load, overloading the client/server.
  3. Data Exhaustion: On mobile networks, high-bitrate streams burn through GBs of data in minutes.

The Dual-Stream Architecture Precisely Resolves This:

  • Main Stream Mission: Fidelity storage and detail capture. Record locally/on private network to NVR to ensure clear identification of license plates/faces during playback.
  • Sub Stream Mission:
    • Low Bandwidth Transmission: Real-time push over the public internet without pressure.
    • Low Decoding Cost: Smooth playback on phones/tablets.
    • Multi-Channel on One Screen: Support for dozens of preview channels.
    • AI Optimization: Feed lightweight sources to motion detection/intrusion algorithms to reduce computational burden and improve efficiency.

IV. Development Practice: Code-Level Interaction Guide

  1. Obtaining RTSP Addresses Reference: Comprehensive Guide to RTSP Addresses:

    • Main Stream: rtsp://IP/stream1 (or /main)
    • Sub Stream: rtsp://IP/stream2 (or /sub)
  2. Smart Switching Logic (Enhance User Experience):

    • Default: Pull sub-stream for multi-channel/remote previewing.
    • Interaction: User double-clicks to fullscreen → seamlessly switch to main stream.
    • Dynamic: Monitor bandwidth in real-time; downgrade to sub-stream on poor networks, upgrade to main stream on good networks.
  3. Storage vs. Preview Separation:

    • Recording: Main Stream → NVR/Server (high-quality archiving).
    • Forwarding: Sub Stream → Web/APP/Low-power devices (real-time, low consumption).

Conclusion and Insights

Dual-stream design is an elegant adaptation to scenarios, embodying the principle of graded services under resource constraints:

  • Storage/Detail Priority → Main Stream (High Spec).
  • Bandwidth/Latency/Compute Priority → Sub Stream (Low Spec).

By mastering this concept, developers can accurately configure devices and optimize architectures to build high-performance, user-friendly video systems. When choosing streams next time, make decisive decisions based on business pain points!