Skip to content

Commit 874e28f

Browse files
committed
vo_kitty: Introduce modern sixel alternative
See https://sw.kovidgoyal.net/kitty/graphics-protocol/ This makes no attempt at querying terminal features or handling terminal errors, as it would require mpv to pass the response codes from the terminal to the vo instead of interpreting them as keystrokes made by the user and acting very unpredictably. Tested with kitty and konsole. Fixes #9605
1 parent 7614e68 commit 874e28f

File tree

6 files changed

+480
-0
lines changed

6 files changed

+480
-0
lines changed

DOCS/interface-changes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ Interface changes
2727
::
2828

2929
--- mpv 0.36.0 ---
30+
- add the `--vo=kitty` video output driver, as well as the options
31+
`--vo-kitty-cols`, `--vo-kitty-rows`, `--vo-kitty-width`,
32+
`--vo-kitty-height`, `--vo-kitty-left`, `--vo-kitty-top`,
33+
`--vo-kitty-config-clear`, `--vo-kitty-alt-screen` and
34+
`--vo-kitty-use-shm`
3035
- add `--force-render`
3136
- add `--vo-sixel-config-clear`, `--vo-sixel-alt-screen` and
3237
`--vo-sixel-buffered`

DOCS/man/vo.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,45 @@ Available video output drivers are:
383383
``--vo-tct-256=<yes|no>`` (default: no)
384384
Use 256 colors - for terminals which don't support true color.
385385

386+
``kitty``
387+
Graphical output for the terminal, using the kitty graphics protocol.
388+
Tested with kitty and Konsole.
389+
390+
You may need to use ``--profile=sw-fast`` to get decent performance.
391+
392+
Kitty size and alignment options:
393+
394+
``--vo-kitty-cols=<columns>``, ``--vo-kitty-rows=<rows>`` (default: 0)
395+
Specify the terminal size in character cells, otherwise (0) read it
396+
from the terminal, or fall back to 80x25.
397+
398+
``--vo-kitty-width=<width>``, ``--vo-kitty-height=<height>`` (default: 0)
399+
Specify the available size in pixels, otherwise (0) read it from the
400+
terminal, or fall back to 320x240.
401+
402+
``--vo-kitty-left=<col>``, ``--vo-kitty-top=<row>`` (default: 0)
403+
Specify the position in character cells where the image starts (1 is
404+
the first column or row). If 0 (default) then try to automatically
405+
determine it according to the other values and the image aspect ratio
406+
and zoom.
407+
408+
``--vo-kitty-config-clear=<yes|no>`` (default: yes)
409+
Whether or not to clear the terminal whenever the output is
410+
reconfigured (e.g. when video size changes).
411+
412+
``--vo-kitty-alt-screen=<yes|no>`` (default: yes)
413+
Whether or not to use the alternate screen buffer and return the
414+
terminal to its previous state on exit. When set to no, the last
415+
kitty image stays on screen after quit, with the cursor following it.
416+
417+
``--vo-kitty-use-shm=<yes|no>`` (default: no)
418+
Use shared memory objects to transfer image data to the terminal.
419+
This is much faster than sending the data as escape codes, but is not
420+
supported by as many terminals. It also only works on the local machine
421+
and not via e.g. SSH connections.
422+
423+
This option is not implemented on Windows.
424+
386425
``sixel``
387426
Graphical output for the terminal, using sixels. Tested with ``mlterm`` and
388427
``xterm``.

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ sources = files(
229229
'video/out/vo_libmpv.c',
230230
'video/out/vo_null.c',
231231
'video/out/vo_tct.c',
232+
'video/out/vo_kitty.c',
232233
'video/out/win_state.c',
233234
'video/repack.c',
234235
'video/sws_utils.c',

video/out/vo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ extern const struct vo_driver video_out_wlshm;
6767
extern const struct vo_driver video_out_rpi;
6868
extern const struct vo_driver video_out_tct;
6969
extern const struct vo_driver video_out_sixel;
70+
extern const struct vo_driver video_out_kitty;
7071

7172
const struct vo_driver *const video_out_drivers[] =
7273
{
@@ -118,6 +119,7 @@ const struct vo_driver *const video_out_drivers[] =
118119
#if HAVE_SIXEL
119120
&video_out_sixel,
120121
#endif
122+
&video_out_kitty,
121123
&video_out_lavc,
122124
NULL
123125
};

0 commit comments

Comments
 (0)