obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
60.29k stars 7.99k forks source link

Open the record and replay buffer at the same time, and pause the recording will cause failure to exit the OBS normally #7249

Open TianQiBuTian opened 2 years ago

TianQiBuTian commented 2 years ago

Operating System Info

Windows 10

Other OS

No response

OBS Studio Version

Other

OBS Studio Version (Other)

27.2.4 & 28.0.0-4-g7396c211b

OBS Studio Log URL

https://obsproject.com/logs/KKfLofSh36TK2uFZ

OBS Studio Crash Log URL

No response

Expected Behavior

Exit the OBS normally and save the video file.

Current Behavior

After exit, the video is not saved successfully, and the icon in the lower right corner does not disappear and cannot be operated. Need to end the process in the task manager to exit and save the video successfully.

Steps to Reproduce

  1. Starting Record and Starting Replay Buffer.
  2. Pause Recording.
  3. Exit OBS.

Anything else we should know?

No response

PatTheMav commented 2 years ago

Reproduced on Windows 11, OBS seems stuck in destroying the replay buffer (which was paused when the recording was paused) - the tray icon remains as reported and upon killing the process via Task Manager the video file is actually written.

From what I could tell in the debugger, OBS is stuck at os_event_wait(output->stopping_event); in obs-output.c.

@notr1ch could it be that because the replay buffer was paused due to the recording having been paused, obs_output_actual_stop wasn't called and os_event_reset(output->stopping_event); or os_event_signal(output->stopping_event); never took place?

Scratch that, pausing the output doesn't deactivate it, will investigate further..

PatTheMav commented 2 years ago

My updated theory is that because the recording was paused, this check succeeds:

https://github.com/obsproject/obs-studio/blob/b1c65af2b1c2e7c3554efb0578ca92fd64c4519c/libobs/obs-encoder.c#L1295

The issue seems to be that the end_data_capture_thread (which signals the stopping_event) is only created if the send_audio_data is called below, which leads obs-ffmpeg-mux to check if the current timestamp has exceeded the stopping timestamp (which would call deactivate):

https://github.com/obsproject/obs-studio/blob/b1c65af2b1c2e7c3554efb0578ca92fd64c4519c/plugins/obs-ffmpeg/obs-ffmpeg-mux.c#L837

So: Because the recording is paused, the audio thread skips sending data to the encoder, but if no data is sent to the encoder and obs-ffmpeg-mux the stream is never stopped and the output waits forever for that to happen.

Fenrirthviti commented 2 years ago

Is this potentially related to #7144?

PatTheMav commented 2 years ago

Afaik that one was related to the seek position in the written file not being correctly adjusted and thus we were overwriting data at the same "old" seek position - R1ch might be in a better position to answer that.

PatTheMav commented 2 years ago

Possible duplicate of https://github.com/obsproject/obs-studio/issues/2162.

PatTheMav commented 2 years ago

@notr1ch FYI, maybe you can think of a fix for this?

zandercodes commented 1 year ago

Same problem. When Replay Buffer is on, recording not working and stopping also not working anymore.