Repository navigation
Description
Upstream OBS bug, reported on the OBS forum, not on GitHub: "recording is cut off on application shutdown" (https://obsproject.com/forum/threads/recording-is-cut-off-on-application-shutdown.182904/, December 2024, OBS 30.2.3 on Ubuntu 22.04, no replies). Quitting OBS while it records (Ctrl+Q, or closing it from outside) saves the file, but "a few seconds are missing at the end" compared with clicking Stop Recording first. No GitHub issue found. Still present upstream and in this fork.
Location
frontend/widgets/OBSBasic.cppOBSBasic::closeWindow()(line 1840) stops only the virtual camera (StopVirtualCamForShutdown(), line 1861), then clears the scenes and callsapplicationShutdown().applicationShutdown()(line 1289) destroys the outputs withoutputHandler.reset()(line 1334) while the recording is still running.- Destroying an active output force-stops it (
obs_output_destroy()->obs_output_actual_stop(output, true, 0)), so the packets the video encoder still holds (x264's lookahead and B-frames) never reach the file. Stop Recording callsobs_output_stop()instead: the muxer keeps writing until it has every packet up to the moment of the stop.
Class
Data loss: the end of the recording is missing.
How it is reached
Quit while a recording is active: File > Exit, Ctrl+Q, closing the main window, SIGINT, or SIGTERM (session logout, kill). With "Show confirmation dialog when quitting" on (the default), the loss happens after the user clicks OK on "OBS is still currently active. All streams/recordings will be shut down."
Reproduced in the current release
AppImage v0.1.0-beta.20261014, headless (private Xvfb, private HOME, dbus-run-session, --multi). Simple output mode, x264 (Small, veryfast), MKV, 640x360 at 30 fps, a looping Media Source. Recording started over obs-websocket and run for 10 s, then:
| How the recording ends | Video frames in the file | Expected | Duration |
|---|---|---|---|
| Stop Recording, then quit (control) | 301 | 300 | 10.03 s |
| Quit, confirmation dialog off | 275 | 300 | 9.23 s |
| Quit, confirmation dialog on (default), OK at 11.6 s | 344 | about 364 | 11.50 s |
| Pause at 10 s, quit 1 s later | 280 | 300 | 9.40 s |
| SIGTERM, confirmation dialog off | 277 | 300 | 9.30 s |
The log shows the output force-stopped during shutdown ("Output 'simple_file_output': stopping" right after "==== Shutting down", with no "==== Recording Stop"). About 0.7 s (20 to 25 frames) is lost each time; more with slower x264 presets or larger lookahead.
Proposed fix and failing test
Fix: before closeWindow() clears the scenes, stop an active recording the way Stop Recording does (obs_output_stop()) and wait until it has stopped, at most 5 s. A recording that has not stopped by then is force-stopped, as now, so quitting never hangs on it. The UI's own stop handlers are disconnected first: as now, a quit shows no "Recording saved" message or error dialog and starts no Automatic Remux. Streaming and the Replay Buffer keep their current shutdown.
RED test (cmocka, test_recording_shutdown, Linux, needs a display, skips without one): runs the shutdown step on a real libobs output whose video encoder holds back 12 frames and which stops like obs-ffmpeg-mux, then releases the output as outputHandler.reset() does. Today 42 frames go into the encoder before the quit and only 30 reach the output; a recording that never finishes stopping must also be force-stopped after the timeout, not left running.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 14, 2026
Claiming: this issue.
test_recording_shutdownruns the frontend's quit step on a real libobs output whose video encoder holds back frames like x264's lookahead, then releases the output asoutputHandler.reset()does. Today the held frames never reach the recording, and nothing bounds a recording that does not stop.closeWindow()stops an active recording the way Stop Recording does and waits for it, at most 5 s, before the outputs are destroyed; after that it force-stops it as before, so quitting never hangs.PR today.
test/cmocka: Add failing test for quitting OBS while recording
frontend: Stop the recording before quitting instead of dropping its end
frontend: Stop the recording before quitting instead of dropping its …