You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In particular, @jquast proposes the use of sextants and octants that respectively reduce the video size to 80x48 and 80x36 terminal characters.
There is also another approach that I quickly implemented here: c2caf7d
It uses PIL.image.thumbnail to scale the video buffer down to a size that fits within the current terminal size. It uses the NEAREST scaling method by default, but F1 can be used at runtime to cycle the scaling methods.
scale-to-term.mp4
Both approach have their merits:
The sextants approach has higher fidelity (only a small fraction of the pixels are rendered with the wrong color), but it jumps from sextants to half blocks with nothing in between, and the aspect ratio is not preserved
The thumbnail approach smoothly scales the video, but more information is lost during the process (as it changes the size in pixels). Also Pillow is a pretty big wheel (about 6MB), so that would probably mean re-write the scaling code in a cython extension rather than depending on Pillow.
What I would like to experiment next is a hybrid approach: if we consider that the proper aspect ratio is given by the fact that a terminal character is 1:2, then we could squeeze the 160x144 pixels in a video frame to a160x108 pixel image, that we can then blit using sextants. That means we'll get 80x36 terminal characters, exactly like we would with octants, achieving the same aspect ratio as the current implementation. Similarly, we can stretch the frame into a 214x144 pixel image, for a sextants result of 107x48 terminal characters.
There have been ongoing discussions about adapting the video to the current terminal size:
In particular, @jquast proposes the use of sextants and octants that respectively reduce the video size to
80x48and80x36terminal characters.There is also another approach that I quickly implemented here: c2caf7d
It uses
PIL.image.thumbnailto scale the video buffer down to a size that fits within the current terminal size. It uses theNEARESTscaling method by default, butF1can be used at runtime to cycle the scaling methods.scale-to-term.mp4
Both approach have their merits:
What I would like to experiment next is a hybrid approach: if we consider that the proper aspect ratio is given by the fact that a terminal character is
1:2, then we could squeeze the160x144pixels in a video frame to a160x108pixel image, that we can then blit using sextants. That means we'll get80x36terminal characters, exactly like we would with octants, achieving the same aspect ratio as the current implementation. Similarly, we can stretch the frame into a214x144pixel image, for a sextants result of107x48terminal characters.