player: add option to disable video OSD

Normally, OSD can be disabled with --osd-level=0. But this also disables
terminal OSD, and some users want _only_ the terminal OSD. Add
--video-osd=no, which essentially disables the video OSD.

Ideally, it should probably be possible to control terminal and video
OSD levels independently, but that would require separate OSD timers
(and other state) for both components, so don't do it. But because the
current situation isn't too ideal, add a threat to the manpage that
might be changed in the future.

Fixes #3387.
This commit is contained in:
wm4 2016-08-28 18:15:37 +02:00
parent 7af6e64db7
commit 5086b2d456
4 changed files with 33 additions and 8 deletions

View File

@ -2890,6 +2890,17 @@ OSD
Default: 0.
``--video-osd=<yes|no>``
Enabled OSD rendering on the video window (default: yes). This can be used
in situations where terminal OSD is preferred. If you just want to disable
all OSD rendering, use ``--osd-level=0``.
It does not affect subtitles or overlays created by scripts (in particular,
the OSC needs to be disabled with ``--no-osc``).
This option is somewhat experimental and could be replaced by another
mechanism in the future.
Screenshot
----------
@ -3136,11 +3147,15 @@ Terminal
Only show warnings or worse, and let the ao_alsa output show errors
only.
``--term-osd, --no-term-osd``, ``--term-osd=force``
Display OSD messages on the console when no video output is available.
Enabled by default.
``--term-osd=<auto|no|force>``
Control whether OSD messages are shown on the console when no video output
is available (default: auto).
``force`` enables terminal OSD even if a video window is created.
:auto: use terminal OSD if no video output active
:no: disable terminal OSD
:force: use terminal OSD even if video output active
The ``auto`` mode also enables terminal OSD if ``--video-osd=no`` was set.
``--term-osd-bar``, ``--no-term-osd-bar``
Enable printing a progress bar under the status line on the terminal.

View File

@ -589,6 +589,8 @@ const m_option_t mp_opts[] = {
OPT_STRING("osd-msg2", osd_msg[1], 0),
OPT_STRING("osd-msg3", osd_msg[2], 0),
OPT_FLAG("video-osd", video_osd, 0),
OPT_CHOICE("idle", player_idle_mode, 0,
({"no", 0},
{"once", 1},
@ -739,6 +741,7 @@ const struct MPOpts mp_default_opts = {
.gamma_contrast = 1000,
.gamma_saturation = 1000,
.gamma_hue = 1000,
.video_osd = 1,
.osd_level = 1,
.osd_duration = 1000,
.osd_bar_align_y = 0.5,

View File

@ -127,6 +127,8 @@ typedef struct MPOpts {
int osd_level;
int osd_duration;
int osd_fractions;
int video_osd;
int untimed;
char *stream_capture;
char *stream_dump;

View File

@ -117,8 +117,8 @@ void term_osd_set_subs(struct MPContext *mpctx, const char *text)
static void term_osd_set_text_lazy(struct MPContext *mpctx, const char *text)
{
if ((mpctx->video_out && mpctx->opts->term_osd != 1) ||
!mpctx->opts->term_osd || !text)
bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
if ((video_osd && mpctx->opts->term_osd != 1) || !text)
text = ""; // disable
talloc_free(mpctx->term_osd_text);
mpctx->term_osd_text = talloc_strdup(mpctx, text);
@ -325,7 +325,8 @@ void set_osd_bar(struct MPContext *mpctx, int type,
double min, double max, double neutral, double val)
{
struct MPOpts *opts = mpctx->opts;
if (opts->osd_level < 1 || !opts->osd_bar_visible || !mpctx->video_out)
bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
if (opts->osd_level < 1 || !opts->osd_bar_visible || !video_osd)
return;
mpctx->osd_visible = mp_time_sec() + opts->osd_duration / 1000.0;
@ -460,7 +461,8 @@ static void add_seek_osd_messages(struct MPContext *mpctx)
}
if (mpctx->add_osd_seek_info & OSD_SEEK_INFO_TEXT) {
// Never in term-osd mode
if (mpctx->video_out && mpctx->opts->term_osd != 1) {
bool video_osd = mpctx->video_out && mpctx->opts->video_osd;
if (video_osd && mpctx->opts->term_osd != 1) {
if (set_osd_msg(mpctx, 1, mpctx->opts->osd_duration, ""))
mpctx->osd_show_pos = true;
}
@ -564,6 +566,9 @@ void update_osd_msg(struct MPContext *mpctx)
term_osd_print_status_lazy(mpctx);
term_osd_update(mpctx);
if (!opts->video_osd)
return;
int osd_level = opts->osd_level;
if (mpctx->osd_show_pos)
osd_level = 3;