obs-ffmpeg/ffmpeg-mux: Use separate printable URL target

(Jim) printable_file allows the ability to keep a separate string for
logging which will not contain things like stream keys when used with
outputs such as HLS.
This commit is contained in:
Maya Venkatraman 2020-10-13 12:33:32 -07:00 committed by jp9000
parent 04596ec097
commit 966b48a0f7
4 changed files with 19 additions and 5 deletions

View File

@ -15,6 +15,7 @@ add_executable(obs-ffmpeg-mux
${obs-ffmpeg-mux_HEADERS})
target_link_libraries(obs-ffmpeg-mux
libobs
${FFMPEG_LIBRARIES})
set_target_properties(obs-ffmpeg-mux PROPERTIES FOLDER "plugins/obs-ffmpeg")

View File

@ -26,6 +26,7 @@
#include <stdlib.h>
#include "ffmpeg-mux.h"
#include <util/dstr.h>
#include <libavformat/avformat.h>
#define ANSI_COLOR_RED "\x1b[0;91m"
@ -73,6 +74,8 @@ static inline void resize_buf_free(struct resize_buf *rb)
struct main_params {
char *file;
/* printable_file is file with any stream key information removed */
struct dstr printable_file;
int has_video;
int tracks;
char *vcodec;
@ -175,6 +178,8 @@ static void ffmpeg_mux_free(struct ffmpeg_mux *ffm)
free(ffm->audio);
}
dstr_free(&ffm->params.printable_file);
memset(ffm, 0, sizeof(*ffm));
}
@ -317,6 +322,8 @@ static bool init_params(int *argc, char ***argv, struct main_params *params,
*p_audio = audio;
dstr_copy(&params->printable_file, params->file);
#ifdef DEBUG_FFMPEG
av_log_set_callback(ffmpeg_log_callback);
#endif
@ -559,7 +566,8 @@ static inline int open_output_file(struct ffmpeg_mux *ffm)
AVIO_FLAG_WRITE);
if (ret < 0) {
fprintf(stderr, "Couldn't open '%s', %s\n",
ffm->params.file, av_err2str(ret));
ffm->params.printable_file.array,
av_err2str(ret));
return FFM_ERROR;
}
}
@ -586,8 +594,8 @@ static inline int open_output_file(struct ffmpeg_mux *ffm)
ret = avformat_write_header(ffm->output, &dict);
if (ret < 0) {
fprintf(stderr, "Error opening '%s': %s\n", ffm->params.file,
av_err2str(ret));
fprintf(stderr, "Error opening '%s': %s",
ffm->params.printable_file.array, av_err2str(ret));
av_dict_free(&dict);
@ -622,7 +630,7 @@ static int ffmpeg_mux_init_context(struct ffmpeg_mux *ffm)
if (output_format == NULL) {
fprintf(stderr, "Couldn't find an appropriate muxer for '%s'\n",
ffm->params.file);
ffm->params.printable_file.array);
return FFM_ERROR;
}

View File

@ -70,6 +70,7 @@ static void ffmpeg_mux_destroy(void *data)
os_process_pipe_destroy(stream->pipe);
dstr_free(&stream->path);
dstr_free(&stream->printable_path);
bfree(stream);
}
@ -354,7 +355,10 @@ int deactivate(struct ffmpeg_muxer *stream, int code)
os_atomic_set_bool(&stream->active, false);
os_atomic_set_bool(&stream->sent_headers, false);
info("Output of file '%s' stopped", stream->path.array);
info("Output of file '%s' stopped",
dstr_is_empty(&stream->printable_path)
? stream->path.array
: stream->printable_path.array);
}
if (code) {

View File

@ -20,6 +20,7 @@ struct ffmpeg_muxer {
volatile bool capturing;
volatile bool stopping;
struct dstr path;
struct dstr printable_path;
/* replay buffer */
int64_t cur_size;