0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-19 19:42:24 +02:00

player/main: select msg output stream early

This avoids printing any stray messages in encode output stream.

--o is already pre-parse cli option which is designed to be parsed
before anything else is printed to output. So we can use that to force
stderr output if needed for encode mode.
This commit is contained in:
Kacper Michajłow 2024-05-05 16:42:28 +02:00
parent 425c6d03d7
commit 414c47d1d8
3 changed files with 19 additions and 6 deletions

View File

@ -117,12 +117,6 @@ struct encode_lavc_context *encode_lavc_init(struct mpv_global *global)
if (!strcmp(filename, "-"))
filename = "pipe:1";
if (filename && (
!strcmp(filename, "/dev/stdout") ||
!strcmp(filename, "pipe:") ||
!strcmp(filename, "pipe:1")))
mp_msg_force_stderr(global, true);
encode_lavc_discontinuity(ctx);
p->muxer = avformat_alloc_context();
@ -946,4 +940,17 @@ fail:
return false;
}
void encoder_update_log(struct mpv_global *global)
{
struct encode_opts *options = mp_get_config_group(NULL, global, &encode_config);
if (options->file && (!strcmp(options->file, "-") ||
!strcmp(options->file, "/dev/stdout") ||
!strcmp(options->file, "pipe:") ||
!strcmp(options->file, "pipe:1")))
{
mp_msg_force_stderr(global, true);
}
talloc_free(options);
}
// vim: ts=4 sw=4 et

View File

@ -111,4 +111,6 @@ bool encoder_encode(struct encoder_context *p, AVFrame *frame);
// Caller needs to acquire encode_lavc_context.lock (or call it from on_ready).
AVRational encoder_get_mux_timebase_unlocked(struct encoder_context *p);
void encoder_update_log(struct mpv_global *global);
#endif

View File

@ -44,6 +44,7 @@
#include "options/m_option.h"
#include "options/m_property.h"
#include "common/common.h"
#include "common/encode_lavc.h"
#include "common/msg.h"
#include "common/msg_control.h"
#include "common/stats.h"
@ -139,6 +140,9 @@ void mp_update_logging(struct MPContext *mpctx, bool preinit)
if (enabled && !preinit && mpctx->opts->consolecontrols)
terminal_setup_getch(mpctx->input);
if (enabled)
encoder_update_log(mpctx->global);
}
void mp_print_version(struct mp_log *log, int always)