Files
scrypted/plugins/prebuffer-mixin
thllxb c5fc35ed6d fix(rebroadcast): do not send getStreamLength before play in RTMP client (#2056)
ffmpeg's libavformat RTMP client (gen_get_stream_length in rtmpproto.c) only sends getStreamLength for seekable/VOD streams, never as an unconditional preamble to play. Some live RTMP servers - notably Reolink cameras - respond to an unsolicited getStreamLength on a live stream by sending TCP FIN ~100-150ms later, killing the connection before the play command can take effect. The rebroadcast prebuffer then enters a tight reconnect loop that never produces a usable stream.

Removing the unconditional getStreamLength send lets Reolink RTMP rebroadcast work indefinitely without disconnects, and should not regress other servers since ffmpeg already runs without it.

Fixes #2055

Co-authored-by: thllxb <223556219+Copilot@users.noreply.github.com>
2026-06-01 15:18:01 -07:00
..
2025-11-13 09:40:28 -08:00
2021-08-24 21:22:41 -07:00
2025-11-13 09:40:28 -08:00
2026-02-26 08:42:31 -08:00
2026-02-26 08:42:31 -08:00

Rebroadcast and Prebuffer for Scrypted

This plugin maintains connections to all connected cameras, and buffers a small amount of recent video for instant replays. This instant replay is used by HomeKit Secure Video, as well as speeding up initial live stream load times.

Stream Setup

The Rebroadcast Plugin will automatically select the best stream depending on the use. For example, a Unifi Camera has 3 available streams: High, Medium, and Low. Rebroadcast will automatically Prebuffer High for HomeKit Secure Video, and the stream selection will use the following defaults:

High: Local Stream (HomeKit on LAN) and Local Recording Stream (NVR) Medium: Remote (Medium Resolution) Stream (HomeKit on cellular) and Remote Recording Stream (HomeKit Secure Video) Low: Low Resolution Stream for Apple Watch, Video Analysis

Most cameras have at least 2 streams available and should be set up as follows:

High: 1080p+ (2000 Kbps) Medium: 720p (500 Kbps) Low (if available): 320p (100 Kbps)

The Key Frame (IDR) Interval should be set to 4 seconds. This setting is usually configured in frames. So if the camera frame rate is 30, the interval would be 120. If the camera frame rate is 15 the interval would be 60. The value can be calculated as IDR Interval = FPS * 4.