Skip to content

always-available: support disabling recording when the source is offline - #6182

Merged
aler9 merged 3 commits into
bluenviron:mainfrom
xodbs1021:always-available-recorded-v2
Sep 5, 2026
Merged

aler9 merged 3 commits into
bluenviron:mainfrom
xodbs1021:always-available-recorded-v2

Conversation

@xodbs1021

Copy link
Copy Markdown
Contributor

Supersedes #5767 by @AbdElrahmaN31. Their commit is kept as the first commit of this branch, rebased onto main.
Closes #5587

Problem

With alwaysAvailable: yes and record: yes, the offline segment is recorded whenever the source is offline, so recordings fill up with the placeholder picture. #5767 adds alwaysAvailableRecorded to skip it. It has been open since May without further activity from its author; I left a review on it with the two gaps below and a suggested fix, and it no longer merges cleanly onto main (internal/core/path.go, internal/conf/conf_test.go).

Change

New path parameter alwaysAvailableRecorded (default true, existing behaviour unchanged). When false, recording runs only while a source is connected and stops while the offline segment is playing.

Reproduction

Config: alwaysAvailable: yes, alwaysAvailableRecorded: false, record: yes, one H264 track. The three regression tests from this branch, run against the original commit alone, show two gaps:

--- PASS: TestPathRecordAlwaysAvailableRecorded (4.14s)
--- FAIL: TestPathRecordAlwaysAvailableRecordedStaticSource (10.01s)
        recording did not start after the static source connected
--- FAIL: TestPathRecordAlwaysAvailableRecordedReloadWhileOffline (2.51s)
        recording started during a reload while the source was offline
  1. Recording was started in doAddPublisher() only, so a path with source: set (static source) never started recording when its source connected.
  2. doReloadConf() used pa.source != nil as the online check. That is true for a static source even while it is disconnected, so a reload while offline started recording the offline segment.

Fix

Recording start and stop now live in setOnline() / setOffline(), which publishers and static sources both go through, and the reload check uses isOnline(). Same tests on this branch:

--- PASS: TestPathRecordAlwaysAvailableRecorded (4.15s)
--- PASS: TestPathRecordAlwaysAvailableRecordedStaticSource (9.31s)
--- PASS: TestPathRecordAlwaysAvailableRecordedReloadWhileOffline (2.51s)

Impact

  • Default true: no change for existing configurations.
  • mediamtx.yml documents the parameter; api/openapi.yaml is regenerated with apidocsgen.
  • Regression tests cover the publisher connect/disconnect cycle, the static source and the reload while offline.

AbdElrahmaN31 and others added 2 commits September 3, 2026 15:02
…luenviron#5587)

Add `alwaysAvailableRecorded` parameter that controls whether recording
happens during offline periods for always-available paths. When set to
false, recording only starts when a real source is connected.
Recording start/stop now rides the shared setOnline/setOffline transitions and
the reload gate uses isOnline(). Static-source paths start recording when the
source connects, and a config reload while the source is offline no longer
records the offline segment. Adds the parameter to the sample configuration and
regression tests for both transitions plus the publisher connect/disconnect cycle.

Co-authored-by: Abdulrahman Nashaat <abdelrahmanndev@gmail.com>
@codecov

codecov Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.52%. Comparing base (c64b687) to head (1f56520).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6182      +/-   ##
==========================================
+ Coverage   64.49%   64.52%   +0.03%     
==========================================
  Files         275      275              
  Lines       23937    23946       +9     
==========================================
+ Hits        15438    15452      +14     
+ Misses       7261     7252       -9     
- Partials     1238     1242       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xodbs1021 xodbs1021 changed the title support disabling recording when the source is offline always-available: support disabling recording when the source is offline Sep 4, 2026
@aler9
aler9 merged commit 1a6e23a into bluenviron:main Sep 5, 2026
12 checks passed
@aler9

aler9 commented Sep 5, 2026

Copy link
Copy Markdown
Member

merged, thanks!

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

This issue is mentioned in release v1.21.0 🚀
Check out the entire changelog by clicking here

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.

Add option to prevent 24/7 recording when alwaysAvailable is enabled

3 participants