浏览代码

obs-outputs: Attempt to generate path if one is not specified

Changes the MP4 muxer to attempt to use the path generation logic if
a path is not explicitly specified. This allows MP4 muxer outputs to
be configured with file splitting, without requiring both the `path`
and `directory`+`format` fields to be specified (saving effort on
the side of developers of custom plugins).
tt2468 11 月之前
父节点
当前提交
9f4e0c52e1
共有 1 个文件被更改,包括 11 次插入4 次删除
  1. 11 4
      plugins/obs-outputs/mp4-output.c

+ 11 - 4
plugins/obs-outputs/mp4-output.c

@@ -239,6 +239,8 @@ static int parse_custom_options(const char *opts_str)
 	return flags;
 }
 
+static void generate_filename(struct mp4_output *out, struct dstr *dst, bool overwrite);
+
 static bool mp4_output_start(void *data)
 {
 	struct mp4_output *out = data;
@@ -250,17 +252,22 @@ static bool mp4_output_start(void *data)
 
 	os_atomic_set_bool(&out->stopping, false);
 
-	/* get path */
 	obs_data_t *settings = obs_output_get_settings(out->output);
-	const char *path = obs_data_get_string(settings, "path");
-	dstr_copy(&out->path, path);
-
 	out->max_time = obs_data_get_int(settings, "max_time_sec") * 1000000LL;
 	out->max_size = obs_data_get_int(settings, "max_size_mb") * 1024 * 1024;
 	out->split_file_enabled = obs_data_get_bool(settings, "split_file");
 	out->allow_overwrite = obs_data_get_bool(settings, "allow_overwrite");
 	out->cur_size = 0;
 
+	/* Get path */
+	const char *path = obs_data_get_string(settings, "path");
+	if (path && *path) {
+		dstr_copy(&out->path, path);
+	} else {
+		generate_filename(out, &out->path, out->allow_overwrite);
+		info("Output path not specified. Using generated path '%s'", out->path.array);
+	}
+
 	/* Allow skipping the remux step for debugging purposes. */
 	const char *muxer_settings = obs_data_get_string(settings, "muxer_settings");
 	out->flags = parse_custom_options(muxer_settings);