Skip to content

bug: frontend: quitting OBS while recording cuts the end off the recording (forum thread 182904) #780

Closed

Description

@rdoupe

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.cpp OBSBasic::closeWindow() (line 1840) stops only the virtual camera (StopVirtualCamForShutdown(), line 1861), then clears the scenes and calls applicationShutdown().
  • applicationShutdown() (line 1289) destroys the outputs with outputHandler.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 calls obs_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.

Activity

  1. rdoupe commented on Oct 14, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_recording_shutdown runs the frontend's quit step on a real libobs output whose video encoder holds back frames like x264's lookahead, then releases the output as outputHandler.reset() does. Today the held frames never reach the recording, and nothing bounds a recording that does not stop.
    2. GREEN: 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.
  2. added
    claimed
    on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions