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)master
parent
d7e673d23d
commit
c4e71794d9
|
@ -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(¶ms->printable_file, params->file);
|
||||
|
||||
get_opt_str(argc, argv, &global_stream_key, "stream key");
|
||||
if (strcmp(global_stream_key, "") != 0) {
|
||||
dstr_replace(¶ms->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;
|
||||
|
|
Loading…
Reference in New Issue