From 974cd4350b8ac8dc7e6b24a32bed491c3b1e9ac1 Mon Sep 17 00:00:00 2001 From: Jeremy Cole Date: Mon, 25 May 2020 15:35:02 -0700 Subject: [PATCH] obs-ffmpeg: Allow continuous network streaming This change breaks the tying of the 'close' option to the media source being a local file vs. network source. In doing so, it is possible to keep network sources streaming continuously, which fixes a few things when using network cameras as sources: * The preview pane works in studio mode. * There is no delay in switching scenes before video appears. * The multiview works properly/normally. This does introduce one bit of weirdness which could be easily fixed with sufficient knowledge of OBS to do it quickly: if a networked media source fails with both 'Restart playback when source becomes active' and 'Close file when inactive' disabled, it is slightly tricky to get it to restart the video stream. (It can be done by enabling those options and hiding the scene, though.) It would be nice to have a simple "restart stream" button somewhere to do this more easily. --- plugins/obs-ffmpeg/obs-ffmpeg-source.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-source.c b/plugins/obs-ffmpeg/obs-ffmpeg-source.c index e28d8b8f2..410ee1c02 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-source.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-source.c @@ -87,8 +87,6 @@ static bool is_local_file_modified(obs_properties_t *props, obs_property_t *local_file = obs_properties_get(props, "local_file"); obs_property_t *looping = obs_properties_get(props, "looping"); obs_property_t *buffering = obs_properties_get(props, "buffering_mb"); - obs_property_t *close = - obs_properties_get(props, "close_when_inactive"); obs_property_t *seekable = obs_properties_get(props, "seekable"); obs_property_t *speed = obs_properties_get(props, "speed_percent"); obs_property_t *reconnect_delay_sec = @@ -96,7 +94,6 @@ static bool is_local_file_modified(obs_properties_t *props, obs_property_set_visible(input, !enabled); obs_property_set_visible(input_format, !enabled); obs_property_set_visible(buffering, !enabled); - obs_property_set_visible(close, enabled); obs_property_set_visible(local_file, enabled); obs_property_set_visible(looping, enabled); obs_property_set_visible(speed, enabled); @@ -392,8 +389,6 @@ static void ffmpeg_source_update(void *data, obs_data_t *settings) input = (char *)obs_data_get_string(settings, "local_file"); input_format = NULL; s->is_looping = obs_data_get_bool(settings, "looping"); - s->close_when_inactive = - obs_data_get_bool(settings, "close_when_inactive"); } else { input = (char *)obs_data_get_string(settings, "input"); input_format = @@ -404,7 +399,6 @@ static void ffmpeg_source_update(void *data, obs_data_t *settings) ? 10 : s->reconnect_delay_sec; s->is_looping = false; - s->close_when_inactive = true; if (s->reconnect_thread_valid) { s->stop_reconnect = true; @@ -413,6 +407,9 @@ static void ffmpeg_source_update(void *data, obs_data_t *settings) } } + s->close_when_inactive = + obs_data_get_bool(settings, "close_when_inactive"); + s->input = input ? bstrdup(input) : NULL; s->input_format = input_format ? bstrdup(input_format) : NULL; #ifndef __APPLE__