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: media-playback: RTSP source never reconnects when the camera goes silent (upstream #12958) #189
if (!m->is_local_file) {
av_dict_set(&opts, "stimeout", "30000000", 0);
Class
Logic error: hang with no recovery.
Cause
FFmpeg 5.0 renamed the RTSP demuxer's stimeout option to timeout (default 0, no timeout). avformat_open_input() leaves unknown options unused and OBS frees the dictionary without checking, so RTSP inputs have had no socket timeout on every FFmpeg OBS supports (6.1+). The interrupt callback (media.c:642-656) only aborts on stop/kill.
How it is reached
A Media Source plays an RTSP camera. The camera loses power or the network drops without closing the TCP connection. av_read_frame blocks forever, stop_cb never runs, so media_stopped never sets destroy_media and ffmpeg_source_reconnect never starts. The source stays frozen with nothing in the log.
Reproduced against a localhost mediamtx server: SIGSTOP the server and the source sits at 0 fps for 54 s with no error, over both RTSP/TCP and RTSP/UDP. A clean server restart does reconnect (FFmpeg sees EOF). Workaround today: timeout=5000000 in the source's FFmpeg Options.
Proposed fix and failing test
Fix: for rtsp:///rtsps:// inputs set timeout (≈5 s, microseconds) with AV_DICT_DONT_OVERWRITE, so a user-set value wins. Other protocols use timeout differently, so not blindly for every scheme.
RED test (cmocka, test_media_network_timeout), with the option moved into a small mp_media_set_network_timeouts():
every option set is known to the linked libavformat's RTSP demuxer (av_opt_find): fails on stimeout
RTSP inputs get a socket timeout: fails
a user-set timeout is kept: passes, guards the fix
a fake camera on 127.0.0.1 answers OPTIONS/DESCRIBE/SETUP/PLAY then goes silent; media must stop within 20 s: fails
Cause: OBS sets the RTSP option stimeout, which FFmpeg 5.0 renamed to timeout, so RTSP sources have had no read timeout. A camera that drops off without closing the connection leaves the source frozen forever, and nothing is logged.
Workaround on stock OBS: add timeout=5000000 to the Media Source's FFmpeg Options. The source then gives up on a dead camera after about 10 s and reconnects when it's back.
obs-rust is an AI-assisted fork of OBS; on Arch it's obs-studio-rust-git in the AUR.
If you get a chance to try it, a short reply here on whether it fixes it for you would really help, especially if it does not. Your distro, OBS version and how you capture (camera or server, TCP or UDP) are the useful details.
Activity
rdoupe commentedon Oct 11, 2026
Claiming: this issue.
test_media_network_timeout(4 cases above, 3 failing), option moved intomp_media_set_network_timeouts()with no behaviour change.timeoutfor RTSP inputs without overwriting user options.First PR within a day.
test/cmocka: Add RED RTSP silent-camera tests
media-playback: Time out silent RTSP sources
test/cmocka: Report RTSP timeout test failures portably
rdoupe commentedon Oct 11, 2026
@canadianlocomotivelogistics @fzwoch @djcalcutt @dzek69 you reported or hit this in obsproject/obs-studio#12958 / obsproject/obs-studio#11537, so a heads-up: it's fixed here in obs-rust by #193.
Cause: OBS sets the RTSP option
stimeout, which FFmpeg 5.0 renamed totimeout, so RTSP sources have had no read timeout. A camera that drops off without closing the connection leaves the source frozen forever, and nothing is logged.Workaround on stock OBS: add
timeout=5000000to the Media Source's FFmpeg Options. The source then gives up on a dead camera after about 10 s and reconnects when it's back.obs-rust is an AI-assisted fork of OBS; on Arch it's
obs-studio-rust-gitin the AUR.If you get a chance to try it, a short reply here on whether it fixes it for you would really help, especially if it does not. Your distro, OBS version and how you capture (camera or server, TCP or UDP) are the useful details.