mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
27.82k stars 2.87k forks source link

Command line ouput: mpv overwrites previous lines in terminal buffer #474

Closed wlhlm closed 10 years ago

wlhlm commented 10 years ago

I have mpv running with the following setting:

msglevel = all=error:statusline=status

This silences the by default quite verbose command line output and normally just displays the status line.

Now, when I'm using mpv to play some audio file, the terminal looks like this:

...
$ mpv file.mp3
A: 00:03:47 / 00:8:26 (45%)

When I'm changing the volume, mpv outputs the volume above the status line:

...
Volume: 23%
A: 00:03:47 / 00:8:26 (45%)

It overwrites the shell prompt ($ mpv file.mp2). After some time the volume output disappears and leaves a blank line:

...

A: 00:03:47 / 00:08:26 (45%)

I think the better option is to display it below the status line and not to overwrite the previous lines in the terminal buffer that do not belong to mpv.

I'm not sure whether there are other elements, that also display above the status line.

ghost commented 10 years ago

I think the better option is to display the below the status line and not to overwrite the previous lines in the terminal buffer that do not belong to mpv.

Normally, the status line is the last line on the terminal (at least in the case if there was already enough other output on the terminal before calling mpv), so reserving an extra line for terminal OSD would be weird.

Maybe it should just try to keep track of how many lines it has written before, and print an extra newline when outputting the first line. On the other hand, trying to be too clever with this terminal stuff will probably fail anyway.

Alternatively, you could disable output of these messages with the --no-term-osd option.

ghost commented 10 years ago

Should be fixed in git master now. Report if you have problems.

I won't add this to 0.3.x though - too many/intrusive changes.

wlhlm commented 10 years ago

With the current version (710a45a3864573b18b35f38c5ea8c10bd9e4c63d) there is a bug: mpv would print an addtional line above the statusline every time the terminal-osd is updated. Sample output:

$ mpv file.mp3           
Volume: 28 %
Volume: 28 %
Volume: 28 %

(Paused) A: 00:00:12 / 00:05:11 (4%)
ghost commented 10 years ago

Doesn't happen here. Did you compile with ncurses? What terminal emulator? Output of echo $TERM?

wlhlm commented 10 years ago

I've just rebuilt mpv-git from the AUR (Archlinux). I'm not sure whether ncurses is enabled by default, but it's neither disabled nor enabled in the (AUR-)build script. At least my binary depends on libncursesw.so.

My terminal is rxvt-unicode-9.19 and $TERM is xterm-256color.

ghost commented 10 years ago

I'm also using urxvt, and here $TERM is rxvt-unicode. Can you try to set that? E.g.:

TERM=rxvt-unicode mpv ...

ghost commented 10 years ago

Also, I just pushed a commit which fixes the fallback if termcap/terminfo are not available. (ncurses provides terminfo.)

wlhlm commented 10 years ago

With TERM=rxvt-unicode, it works as expected. So the problem is with xterm256-color where mpv (1cd1fb9e5c39aa858b4f456ce92b506e5f50b768) in the default configuration doesn't even show the terminal-osd and you have to use --term-osd=force.

It also doesn't work correctly with TERM=xterm. That's interesting since, in my experience, xterm as well as xterm-256color are the most compatible with most TUI programs.

ghost commented 10 years ago

The only thing I could imagine is that you really must use tputs() instead of printf() to output the escape sequences.

ghost commented 10 years ago

Hm no, that doesn't change anything. No idea then. I suppose it's not possible that the xterm terminfo entry is broken.

ghost commented 10 years ago

It was a simple mistake. Should work in git master now.

wlhlm commented 10 years ago

:+1: works now correctly.

One minor thing is, that the terminal-osd isn't enabled by default in any of the $TERM configurations and I have to use --term-osd=force.

ghost commented 10 years ago

Thanks for testing this.

One minor thing is, that the terminal-osd isn't enabled by default in any of the $TERM configurations and I have to use --term-osd=force.

That's as intended. If there is a video window, no term OSD is used (just the status line is printed). If there is no video window, term OSD is enabled. $TERM isn't even checked, except for handling the actual output.

wlhlm commented 10 years ago

In my case, there is no video window. I'm using mpv to play some audio files but it will open an annoying window when the there is a cover art so I've put vo=null in my config file.

ghost commented 10 years ago

Use --no-video, or --audio-display=no (the latter disables display of covert art embedded in audio files).

wlhlm commented 10 years ago

Thank you.