You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: libobs: a recording started while the replay buffer runs waits for the next keyframe (empty/unreadable file, slow stop) (upstream obsproject/obs-studio#12069) #593
Upstream OBS bug, reported by Flopblopper in obsproject/obs-studio#12069 (Windows 10, OBS 31.0.3): with the replay buffer running, stopping a recording takes longer than expected and leaves a broken file; without the replay buffer recordings are fine. The reporter found it happens at frame rates below 30. It is still open upstream, and the code is the same in this fork.
Location
libobs/obs-encoder.csend_first_video_packet(): an output gets no video packet before a keyframe. A recording started while the replay buffer runs joins the video encoder the replay buffer already uses, so it waits for that encoder's next scheduled keyframe. With x264's default keyframe interval (250 frames when no service sets one) that is up to 12.5 s at 20 fps (8.3 s at 30 fps): the lower the frame rate, the longer the wait, matching the report.
plugins/obs-ffmpeg/obs-ffmpeg-mux.cffmpeg_mux_data() finishes a stop only when a packet past the stop time arrives. A recording stopped before the keyframe waits for it, then writes headers and stops: a file of a few hundred bytes that players and ffprobe reject.
Class
Data loss: recordings miss their first seconds, or are empty and unreadable; the stop hangs for seconds.
How it is reached
Simple output (recording and replay buffer share the encoder), any frame rate where the encoder's keyframe interval is longer than the time before the stop; most visible below 30 fps. Start the replay buffer, start recording, stop the recording after a few seconds.
Reproduced in the current release
AppImage 33.0.0-beta6-799, headless, private config, obs-websocket; Simple output, x264 veryfast, mkv, 20 fps, replay buffer 20 s, a Media Source looping a clip; replay buffer started, recording started 3 s later and stopped 6 s after that, twice:
First recording: 0.9 s long (15 video packets) instead of 6 s.
Second recording: StopRecord took 4.79 s; the 717-byte file is unreadable (Duplicate element, invalid as first byte of an EBML number).
Without the replay buffer (an earlier run by another lane): 6 s files, stop in about 1.4 s.
Proposed fix and failing test
Fix: libobs asks a running video encoder for a keyframe when another output starts on it, through a new optional request_keyframe in obs_encoder_info (appended, so the struct stays compatible through obs_register_encoder_s); obs-x264 implements it by making its next frame an IDR frame. Encoders without it behave as before.
RED test (cmocka, test_encoder_join_keyframe, core video under Xvfb): a test encoder with a keyframe every 10 s (or on request), a "replay buffer" output on it, then a "recording" joining: the recording must get its first packet within 1 s (today: nothing within 3 s, no request); controls: the first output makes no request, and an encoder without request_keyframe still works.
@Flopblopper you reported this in obsproject/obs-studio#12069 (with the replay buffer running, starting a recording gives an empty or broken file and stopping it is slow), so a heads-up: it's fixed here in obs-rust by #594, with a regression test.
Cause: a recording started while the replay buffer runs shares the video encoder the replay buffer already started, and an output only starts from a keyframe. So the recording got nothing until the encoder's next keyframe, which with x264's default interval of 250 frames can be 10 s or more at low frame rates. Stopping it waited for that keyframe too, and a short recording ended up empty. OBS had no way to ask a running encoder for a keyframe, so this adds one: when an output joins a running video encoder, it now asks for one, and x264 makes its next frame a keyframe. In the obs-rust release at 20 fps, a 6 s recording held 0.9 s, and a second one took 4.8 s to stop and left an unreadable file; a build with the fix recorded the full 6.1 s every time and stopped in about 1.4 s.
One limit: only x264 handles the request so far. Hardware encoders (NVENC, QSV, AMF, VA-API) and the other FFmpeg-based encoders behave as before; they're follow-ups. I couldn't read your log, so if you use one of those, this won't help yet.
Workaround on stock OBS: set a short keyframe interval (for example 2 s) in the encoder settings, so a joining recording waits at most that long.
Activity
rdoupe commentedon Oct 13, 2026
Claiming: this issue.
test_encoder_join_keyframe(1 of 3 failing): an output joining a running encoder waits for the next scheduled keyframe.PR today.
test/cmocka: Add failing test for an output joining a running encoder
rdoupe commentedon Oct 13, 2026
@Flopblopper you reported this in obsproject/obs-studio#12069 (with the replay buffer running, starting a recording gives an empty or broken file and stopping it is slow), so a heads-up: it's fixed here in obs-rust by #594, with a regression test.
Cause: a recording started while the replay buffer runs shares the video encoder the replay buffer already started, and an output only starts from a keyframe. So the recording got nothing until the encoder's next keyframe, which with x264's default interval of 250 frames can be 10 s or more at low frame rates. Stopping it waited for that keyframe too, and a short recording ended up empty. OBS had no way to ask a running encoder for a keyframe, so this adds one: when an output joins a running video encoder, it now asks for one, and x264 makes its next frame a keyframe. In the obs-rust release at 20 fps, a 6 s recording held 0.9 s, and a second one took 4.8 s to stop and left an unreadable file; a build with the fix recorded the full 6.1 s every time and stopped in about 1.4 s.
One limit: only x264 handles the request so far. Hardware encoders (NVENC, QSV, AMF, VA-API) and the other FFmpeg-based encoders behave as before; they're follow-ups. I couldn't read your log, so if you use one of those, this won't help yet.
Workaround on stock OBS: set a short keyframe interval (for example 2 s) in the encoder settings, so a joining recording waits at most that long.
It will be in the next obs-rust daily release after 0.1.0-beta.20261012: https://github.com/obs-rust/obs-studio/releases (Windows, macOS and Linux builds; on Arch it's
obs-studio-rust-gitin the AUR). obs-rust is an AI-assisted fork of OBS.If you get a chance to try it, a reply here with which encoder you use and whether your recordings come out whole would really help.
libobs, obs-x264: Ask a running encoder for a keyframe when an output…