Skip to content

Preload Streams #1762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Preload Streams #1762

wants to merge 6 commits into from

Conversation

seydx
Copy link
Contributor

@seydx seydx commented Jun 3, 2025

This PR adds a preload feature that allows streams to be initialized at go2rtc startup, which is particularly useful for cameras with slow startup times.

Changes

  • New preload package: Implements a consumer that keeps streams active without requiring active viewers
  • Configuration support: Added preload section to YAML config for specifying streams to preload
  • Stream integration: Extended streams package to support preload consumers with query parameters
  • API endpoints: Added REST API for dynamic preload management

Usage

Configure streams to preload in go2rtc.yaml:

preload:
  camera1:                                     # default: video&audio = ANY
  camera2: "video"                             # preload only video track
  camera3: "video=h264#audio=opus"             # initialize transcoding pipeline

streams:
  camera1: 
    - rtsp://192.168.1.100/stream
  camera2: 
    - rtsp://192.168.1.101/stream  
  camera3: 
    - rtsp://192.168.1.102/h265stream
    - ffmpeg:camera3#video=h264#audio=opus#hardware

API Endpoints

Dynamic preload management via REST API:

# Add/update preload for a stream
PUT /api/preloads?src=camera3&video=h264&audio=opus

# Remove preload from a stream  
DELETE /api/preloads?src=camera3

Benefits

  • Eliminates cold start delays when accessing streams
  • Maintains active connections to prevent camera timeouts
  • Supports codec filtering and audio configuration
  • Dynamic control via REST API for runtime management

The preload consumer acts as a permanent viewer that keeps the stream pipeline active while consuming minimal resources.

Closes/Addresses/Resolves: #1444 #605 #1344 #530

@gtxaspec
Copy link

gtxaspec commented Jun 3, 2025

yes! thank you!

@AlexxIT AlexxIT self-assigned this Jun 3, 2025
@AlexxIT
Copy link
Owner

AlexxIT commented Jun 3, 2025

@gtxaspec Looks like you've been waiting a long time for this.

@gtxaspec
Copy link

gtxaspec commented Jun 3, 2025

@gtxaspec Looks like you've been waiting a long time for this.

I wait patiently =D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants