浏览代码

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.
Jeremy Cole 5 年之前
父节点
当前提交
974cd4350b
共有 1 个文件被更改,包括 3 次插入6 次删除
  1. 3 6
      plugins/obs-ffmpeg/obs-ffmpeg-source.c

+ 3 - 6
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 *local_file = obs_properties_get(props, "local_file");
 	obs_property_t *looping = obs_properties_get(props, "looping");
 	obs_property_t *looping = obs_properties_get(props, "looping");
 	obs_property_t *buffering = obs_properties_get(props, "buffering_mb");
 	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 *seekable = obs_properties_get(props, "seekable");
 	obs_property_t *speed = obs_properties_get(props, "speed_percent");
 	obs_property_t *speed = obs_properties_get(props, "speed_percent");
 	obs_property_t *reconnect_delay_sec =
 	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, !enabled);
 	obs_property_set_visible(input_format, !enabled);
 	obs_property_set_visible(input_format, !enabled);
 	obs_property_set_visible(buffering, !enabled);
 	obs_property_set_visible(buffering, !enabled);
-	obs_property_set_visible(close, enabled);
 	obs_property_set_visible(local_file, enabled);
 	obs_property_set_visible(local_file, enabled);
 	obs_property_set_visible(looping, enabled);
 	obs_property_set_visible(looping, enabled);
 	obs_property_set_visible(speed, 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 = (char *)obs_data_get_string(settings, "local_file");
 		input_format = NULL;
 		input_format = NULL;
 		s->is_looping = obs_data_get_bool(settings, "looping");
 		s->is_looping = obs_data_get_bool(settings, "looping");
-		s->close_when_inactive =
-			obs_data_get_bool(settings, "close_when_inactive");
 	} else {
 	} else {
 		input = (char *)obs_data_get_string(settings, "input");
 		input = (char *)obs_data_get_string(settings, "input");
 		input_format =
 		input_format =
@@ -404,7 +399,6 @@ static void ffmpeg_source_update(void *data, obs_data_t *settings)
 						 ? 10
 						 ? 10
 						 : s->reconnect_delay_sec;
 						 : s->reconnect_delay_sec;
 		s->is_looping = false;
 		s->is_looping = false;
-		s->close_when_inactive = true;
 
 
 		if (s->reconnect_thread_valid) {
 		if (s->reconnect_thread_valid) {
 			s->stop_reconnect = true;
 			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 = input ? bstrdup(input) : NULL;
 	s->input_format = input_format ? bstrdup(input_format) : NULL;
 	s->input_format = input_format ? bstrdup(input_format) : NULL;
 #ifndef __APPLE__
 #ifndef __APPLE__