提交 c4e71794 编写于 作者: M Maya Venkatraman 提交者: jp9000

obs-ffmpeg: Allow using stream keys with muxer

(Jim) Allows the ability to use stream keys with ffmpeg-mux -- this will
enable the ability to use it with certain services (such as YouTube)
which allow different protocols (such as HLS)
上级 d7e673d2
......@@ -41,6 +41,8 @@
/* ------------------------------------------------------------------------- */
static char *global_stream_key = "";
struct resize_buf {
uint8_t *buf;
size_t size;
......@@ -230,26 +232,31 @@ static void ffmpeg_log_callback(void *param, int level, const char *format,
va_list args)
{
char out_buffer[4096];
struct dstr out = {0};
vsnprintf(out_buffer, sizeof(out_buffer), format, args);
dstr_copy(&out, out_buffer);
dstr_replace(&out, global_stream_key, "{stream_key}");
switch (level) {
case AV_LOG_INFO:
fprintf(stdout, "info: [ffmpeg_muxer] %s", out_buffer);
fprintf(stdout, "info: [ffmpeg_muxer] %s", out.array);
fflush(stdout);
break;
case AV_LOG_WARNING:
fprintf(stdout, "%swarning: [ffmpeg_muxer] %s%s",
ANSI_COLOR_MAGENTA, out_buffer, ANSI_COLOR_RESET);
ANSI_COLOR_MAGENTA, out.array, ANSI_COLOR_RESET);
fflush(stdout);
break;
case AV_LOG_ERROR:
fprintf(stderr, "%serror: [ffmpeg_muxer] %s%s", ANSI_COLOR_RED,
out_buffer, ANSI_COLOR_RESET);
out.array, ANSI_COLOR_RESET);
fflush(stderr);
}
dstr_free(&out);
UNUSED_PARAMETER(param);
}
......@@ -324,6 +331,12 @@ static bool init_params(int *argc, char ***argv, struct main_params *params,
dstr_copy(&params->printable_file, params->file);
get_opt_str(argc, argv, &global_stream_key, "stream key");
if (strcmp(global_stream_key, "") != 0) {
dstr_replace(&params->printable_file, global_stream_key,
"{stream_key}");
}
#ifdef DEBUG_FFMPEG
av_log_set_callback(ffmpeg_log_callback);
#endif
......
......@@ -71,6 +71,7 @@ static void ffmpeg_mux_destroy(void *data)
os_process_pipe_destroy(stream->pipe);
dstr_free(&stream->path);
dstr_free(&stream->printable_path);
dstr_free(&stream->stream_key);
dstr_free(&stream->muxer_settings);
bfree(stream);
}
......@@ -200,6 +201,14 @@ static void log_muxer_params(struct ffmpeg_muxer *stream, const char *settings)
av_dict_free(&dict);
}
static void add_stream_key(struct dstr *cmd, struct ffmpeg_muxer *stream)
{
dstr_catf(cmd, "\"%s\" ",
dstr_is_empty(&stream->stream_key)
? ""
: stream->stream_key.array);
}
static void add_muxer_params(struct dstr *cmd, struct ffmpeg_muxer *stream)
{
struct dstr mux = {0};
......@@ -260,6 +269,7 @@ static void build_command_line(struct ffmpeg_muxer *stream, struct dstr *cmd,
}
}
add_stream_key(cmd, stream);
add_muxer_params(cmd, stream);
}
......
......@@ -22,6 +22,7 @@ struct ffmpeg_muxer {
struct dstr path;
struct dstr printable_path;
struct dstr muxer_settings;
struct dstr stream_key;
/* replay buffer */
int64_t cur_size;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册