Skip to content

Hybrid Replay Buffer#12505

Open
derrod wants to merge 2 commits into
obsproject:masterfrom
derrod:hybrid-replay-buffer
Open

Hybrid Replay Buffer#12505
derrod wants to merge 2 commits into
obsproject:masterfrom
derrod:hybrid-replay-buffer

Conversation

@derrod

@derrod derrod commented Aug 14, 2025

Copy link
Copy Markdown
Member

Description

Implements replay buffer using the Hybrid MP4/MOV muxer instead of FFmpeg.

Motivation and Context

  • Feature parity with FFmpeg output
  • Consistency between recording/replay buffer
  • New features!

This implements a second hotkey as often requested (e.g. on Fider) that will dump the contents of the buffer after saving so two replay buffers saved back to back do not contain the same content1

How Has This Been Tested?

Tested locally with both hotkeys and HEVC.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Footnotes

  1. Currently saving is allowed on non-keyframes, and discarding only happens up until the last keyframe. So there can be a few seconds of overlap still.

@WizardCM WizardCM added the kind/feature Functionality or other elements that the project doesn't currently have. label Aug 16, 2025
@derrod derrod force-pushed the hybrid-replay-buffer branch 2 times, most recently from be6d60f to 48b0224 Compare August 21, 2025 23:00
@derrod derrod marked this pull request as ready for review August 21, 2025 23:02
@derrod derrod force-pushed the hybrid-replay-buffer branch from 48b0224 to 9478073 Compare August 21, 2025 23:10
@Warchamp7

Copy link
Copy Markdown
Member

The additional hotkey option was my proposal in lieu of a checkbox so I'm fine with this on the UX front.

@derrod derrod force-pushed the hybrid-replay-buffer branch from 9478073 to e3db9ea Compare November 10, 2025 20:12
@derrod derrod force-pushed the hybrid-replay-buffer branch from e3db9ea to 6526a6b Compare November 27, 2025 21:32
@derrod

derrod commented Nov 27, 2025

Copy link
Copy Markdown
Member Author

Fixed up a rebase whoopsie that broke the build. Should be g2g now.

Comment thread plugins/obs-outputs/mp4-output.c
@derrod derrod force-pushed the hybrid-replay-buffer branch from 6526a6b to 405e7de Compare January 9, 2026 20:41
@exeldro

exeldro commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Would it be much work to support multi track video for the replay buffer?

@derrod

derrod commented Jan 9, 2026

Copy link
Copy Markdown
Member Author

Would it be much work to support multi track video for the replay buffer?

Mh, does it not work? I suppose there might be some nuance with how purging the buffer works that could result in tracks not starting at the same time.

@exeldro

exeldro commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

The "mp4_replay_buffer" output does not have the multi track video flag set, so I would think it does not work, but I have not tried it yet.

@derrod

derrod commented Jan 9, 2026

Copy link
Copy Markdown
Member Author

The "mp4_replay_buffer" output does not have the multi track video flag set, so I would think it does not work, but I have not tried it yet.

Ah I see, adding that part would be trivial for sure. I would be concerned about sync, since the DTS of keyframes can vary across tracks if b-frames are in use. I'd probably have to add a check to find the IDR on the primary track and then work forwards/backwards to find them for all the other tracks as well to determine a safe cutoff point.

In revisiting the code I also noticed that it just hardcodes a single flag (MP4_USE_NEGATIVE_CTS) which is technically valid but we'd probably want to reuse whatever is set for the primary output here too.

@derrod derrod force-pushed the hybrid-replay-buffer branch 3 times, most recently from 599153b to c3b3d18 Compare January 9, 2026 22:23
@derrod

derrod commented Jan 9, 2026

Copy link
Copy Markdown
Member Author

Updated with the following:

  • Added OBS_OUTPUT_MULTI_TRACK_AV flag since that should work more or less fine, but let's call it experimental
  • Added MOV replay buffer (this PR predates Hybrid MOV being merged so it didn't have it)
  • Ensured that flags in muxer_settings are parsed and passed-through to replay mux thread

@derrod derrod force-pushed the hybrid-replay-buffer branch 2 times, most recently from e92f6c9 to ea7a9cb Compare July 8, 2026 12:53
@chewybluff

Copy link
Copy Markdown

Is it supposed to work in current state? With hybrid mov/mp4 both hotkeys to save replay produce 0kb files and no info in logs, i've tried some artifact builds a while ago, and now built from source

@derrod derrod force-pushed the hybrid-replay-buffer branch from ea7a9cb to 10eb314 Compare July 10, 2026 06:47
@derrod

derrod commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

Is it supposed to work in current state? With hybrid mov/mp4 both hotkeys to save replay produce 0kb files and no info in logs, i've tried some artifact builds a while ago, and now built from source

It seems there was a typo that made its way in during one of the rebases or something. It should be fixed now.

@chewybluff

Copy link
Copy Markdown

The file is being saved now, though there is no "replay buffer saved to" message in obs window and log. Sadly, no overshoot fixes here

@derrod

derrod commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

The file is being saved now, though there is no "replay buffer saved to" message in obs window and log. Sadly, no overshoot fixes here

What do you mean by "overshoot"?

@chewybluff

Copy link
Copy Markdown

The file is being saved now, though there is no "replay buffer saved to" message in obs window and log. Sadly, no overshoot fixes here

What do you mean by "overshoot"?

Overlapping content from previous replay

@Fenrirthviti

Copy link
Copy Markdown
Member

There's nothing to fix there, that is how the replay buffer is currently designed.

We are open to the idea of improving the replay buffer, but it's a finnicky feature that needs care and hasn't been a priority. It's well outside scope of this PR, and not related.

@derrod

derrod commented Jul 11, 2026

Copy link
Copy Markdown
Member Author

The file is being saved now, though there is no "replay buffer saved to" message in obs window and log. Sadly, no overshoot fixes here

What do you mean by "overshoot"?

Overlapping content from previous replay

If you have a short keyframe interval and use the discard hotkey the overlap will be short. But it's somewhat unavoidable unless we implement a delay that waits until the next keyframe to do a clean cut (similar to how file splitting works). But if the encoder is configured with a very long keyframe interval it could take a long time for the replay to be able to save.

@derrod derrod force-pushed the hybrid-replay-buffer branch from 10eb314 to 05316d9 Compare July 13, 2026 00:16
@derrod derrod added the Seeking Testers Build artifacts on CI label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Functionality or other elements that the project doesn't currently have. Seeking Testers Build artifacts on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants