jarun / nnn

n³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
18.78k stars 749 forks source link

mpv sixel/kitty support for preview #1590

Closed mia-0 closed 1 year ago

mia-0 commented 1 year ago

So I don’t use nnn but I’ve added kitty support to mpv a while ago and I’m using it in a TUI moderation app for my file hoster 0x0.st, so I thought you might be interested in this as an alternative to XEmbed.

In short, with the “buffered” options of its sixel/kitty video outputs, mpv can run “embedded” in other TUI applications to provide video previews. In my app, I’m also using it for images, whether from files or in-memory streams (such as PDF previews from MuPDF). It works well over SSH (provided there is enough network bandwidth—ssh -C helps) and does not require synchronization of terminal output (since its writes are atomic).

N-R-K commented 1 year ago

As far as I see, preview-tui already supports kitty (but I don't see mpv mentioned anywhere). So my understanding is that you're asking to embed an mpv instance inside kitty to do the previews, is that correct?

In any case, this is going to be @luukvbaal's call.

mia-0 commented 1 year ago

Yeah, somewhat analogous to the XEmbed approach in preview-tabbed. So mpv does the rendering and you just tell it where, relative to the terminal window. It could replace image viewers and e.g. calls to ffmpegthumbnailer.

luukvbaal commented 1 year ago

I won't be looking into this as I'm not a kitty user but a PR is welcome AFAIC. I guess https://github.com/mpv-player/mpv/commit/874e28f4a41a916bb567a882063dd2589e9234e1 can be used for reference.

mia-0 commented 1 year ago

It also supports sixels and there’s almost no difference between the two as far as usage goes (see e.g. here).

kuntau commented 1 year ago

Ah... this requires mpv v0.36, no wonder I got error no kitty vo. Latest release still v0.35

mia-0 commented 1 year ago

Right, I forgot that wasn’t actually in any release yet. I’m on a distro that packages git snapshots (as per upstream recommendation)…

jarun commented 1 year ago

I have added this to the tracker as no one is free to pick this up at the moment. Closing accordingly.