I aspire to forget even half the stuff this guy knows. Nick is insanely talented beyond my comprehension... and I have 20 years experience in programming.
I can't even wrap my head around trying to in-place rotate a bitmap in C without pulling my hair out. This guy must do it in his sleep.
Far far better than caca. But if you want a picture-perfect quality try instead mpv with a sixel output
The subset of usable characters (glyphs) roughly defines how accurate the picture can be represented: if all you have is - and _ and you want to represent an horizontal pipe, it'll be ugly.
Of course it's more complicated than that, but caca uses ascii, while chafa uses a larger unicode range.
The example is illustrated in picture on https://github.com/csdvrx/derasterize where the left is the original basicidea.c using only unicode halfblocks, and the right has more candidate of different shapes.
Derasterize lets you select the width of the range you want to use, to improve encoding time say for video - but ideally, you would be able to test that whatever font you are using contains the glyphs you want.
The few times I've ever used libcaca/mplayer to try and play videos, it was on Linux consoles with no working X server, or when I had broken the X server, or I was just amused to try it.
The thing about sixel is it's only supported on old DEC glass terminals, xterm with a non-default configuration, mintty, and several emulators that are fairly unlikely to be preinstalled anywhere. So I struggle to imagine a scenario outside of the novelty of playing video media in a terminal where you'd use sixel for playing video over either a dedicated streaming API (raw video stream, networked X, VNC, waypipe) or accessing media over a networked filesystem (e.g. sshfs, which I regularly use to watch videos).
Images are a different matter, where the compromise makes more sense. Juxtaposing images with terminal output is a nifty feature. But the (IMO limited) utility of programs like caca and chafa is being "universal enough" that I can write a script that vomits a jpeg to some vague common denominator standard and it'll probably work for all my coworkers using a smorgasbord of emulators.
I'm not sure chafa works with video like, say, mplayer built with aalib and libcaca will convert movie files to color or B&W ASCII on the command line (iirc w/ audio only on the host machine). Similarly, on PPC Macs, there was QuickASCII,[1] which lacks audio. I have used tiv,[2] (available with MacPorts) which works very well with images, not video. There was a way to configure the browser links (not lynx) to use tiv to browse the web on cli with converted images.
If you want to see pictures in your terminal but don’t want to install something just for this, the kitty terminal can do it, including over an ssh connection.
Short of swapping in a new image during the vertical blanking interval, you will never have a "flicker" free image. Any "flicker" that can happen from no double buffer can happen because of no vsync. This begs the question why you would ever want to show graphics in the terminal in the first place. I might be wrong, but in my experience most terminal emulators do not look like they can update the full screen 60 times per second. If everyone started doing graphics in the terminal, we will have to find what method can actually output fast enough, or create it and standardize it, and soon we will have a new graphics API that all terminal emulators must conform to or not, and a way for applications to detect whether the terminal supports it.
I was hoping to see a more modern alternative to the VTE terminal protocol and its derivatives. Does anybody have any good suggestions and possible implementations?
The intention is to document them well enough that other terminal emulators can implement them (which some have).
Among those is a graphics protocol, which is actually (optionally) used by chafa. Another is a keyboard protocol extension: which has been implemented by a number of editors and other terminals: notably neovim, kakoune, helix, wezterm, and foot.
I was going for Mexican Spanish, but both interpretations work, cf. cramming symbols together into a lo-fi semblance of the input. Although this might not apply to the kitty/sixel/iterm modes, depending on how you look at it :-)
Just a gif? Where's the presentation? I'm spoiled by the awesome notcurses one[1].
[1] https://www.youtube.com/watch?v=dcjkezf1ARY
I aspire to forget even half the stuff this guy knows. Nick is insanely talented beyond my comprehension... and I have 20 years experience in programming.
I can't even wrap my head around trying to in-place rotate a bitmap in C without pulling my hair out. This guy must do it in his sleep.
How does this compare to using an existing video player with caca?
https://en.wikipedia.org/wiki/Libcaca
Far far better than caca. But if you want a picture-perfect quality try instead mpv with a sixel output
The subset of usable characters (glyphs) roughly defines how accurate the picture can be represented: if all you have is - and _ and you want to represent an horizontal pipe, it'll be ugly.
Of course it's more complicated than that, but caca uses ascii, while chafa uses a larger unicode range.
The example is illustrated in picture on https://github.com/csdvrx/derasterize where the left is the original basicidea.c using only unicode halfblocks, and the right has more candidate of different shapes.
Derasterize lets you select the width of the range you want to use, to improve encoding time say for video - but ideally, you would be able to test that whatever font you are using contains the glyphs you want.
The few times I've ever used libcaca/mplayer to try and play videos, it was on Linux consoles with no working X server, or when I had broken the X server, or I was just amused to try it.
The thing about sixel is it's only supported on old DEC glass terminals, xterm with a non-default configuration, mintty, and several emulators that are fairly unlikely to be preinstalled anywhere. So I struggle to imagine a scenario outside of the novelty of playing video media in a terminal where you'd use sixel for playing video over either a dedicated streaming API (raw video stream, networked X, VNC, waypipe) or accessing media over a networked filesystem (e.g. sshfs, which I regularly use to watch videos).
Images are a different matter, where the compromise makes more sense. Juxtaposing images with terminal output is a nifty feature. But the (IMO limited) utility of programs like caca and chafa is being "universal enough" that I can write a script that vomits a jpeg to some vague common denominator standard and it'll probably work for all my coworkers using a smorgasbord of emulators.
2 replies →
I'm not sure chafa works with video like, say, mplayer built with aalib and libcaca will convert movie files to color or B&W ASCII on the command line (iirc w/ audio only on the host machine). Similarly, on PPC Macs, there was QuickASCII,[1] which lacks audio. I have used tiv,[2] (available with MacPorts) which works very well with images, not video. There was a way to configure the browser links (not lynx) to use tiv to browse the web on cli with converted images.
[1] http://quickascii.sourceforge.net/
[2] https://github.com/radare/tiv
> mplayer built with aalib and libcaca will convert movie files to color or B&W ASCII on the command line
I'm not sure why people expose themselves to something as bad and ugly in this day and age.
Even in 2016 you could use ffmpeg on a sixel-aware terminal like mintty or xterm: check https://www.youtube.com/watch?v=IkUTkqctP28
7 replies →
There's a patch out there to use chafa as output for ffmpeg.
Related:
Chafa 1.8: Terminal graphics with a side of everything - https://news.ycombinator.com/item?id=28548120 - Sept 2021 (23 comments)
If you want to see pictures in your terminal but don’t want to install something just for this, the kitty terminal can do it, including over an ssh connection.
Surely xterm is the mode widely installed terminal emulator with a graphics mode. It emulates the Tektronix 4014 and has done that for decades.
In the article, the author goes over exactly this.
I think it is possible to avoid the flickering via double-buffering, right?
I don't exactly remember how that works. There is the alternate screen buffer:
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-T...
Maybe there was also a special sync terminal escape code or so.
Short of swapping in a new image during the vertical blanking interval, you will never have a "flicker" free image. Any "flicker" that can happen from no double buffer can happen because of no vsync. This begs the question why you would ever want to show graphics in the terminal in the first place. I might be wrong, but in my experience most terminal emulators do not look like they can update the full screen 60 times per second. If everyone started doing graphics in the terminal, we will have to find what method can actually output fast enough, or create it and standardize it, and soon we will have a new graphics API that all terminal emulators must conform to or not, and a way for applications to detect whether the terminal supports it.
I just found this, the synchronized updates spec from iTerm2: https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-upda...
Googling for it, it seems some other terminals implement this as well.
I was hoping to see a more modern alternative to the VTE terminal protocol and its derivatives. Does anybody have any good suggestions and possible implementations?
Yes, kitty has a series of VTE terminal protocol extensions:
https://sw.kovidgoyal.net/kitty/protocol-extensions/
The intention is to document them well enough that other terminal emulators can implement them (which some have).
Among those is a graphics protocol, which is actually (optionally) used by chafa. Another is a keyboard protocol extension: which has been implemented by a number of editors and other terminals: notably neovim, kakoune, helix, wezterm, and foot.
https://github.com/wez/wezterm/issues/986
https://codeberg.org/dnkl/foot/issues/319
chafa in mexican spanish means crappy/cheap
Chafar in Iberian Spanish means to smash/crash down. Also, to break something.
I was going for Mexican Spanish, but both interpretations work, cf. cramming symbols together into a lo-fi semblance of the input. Although this might not apply to the kitty/sixel/iterm modes, depending on how you look at it :-)
2 replies →