hpjansson / chafa

📺🗿 Terminal graphics for the 21st century.
https://hpjansson.org/chafa/
GNU Lesser General Public License v3.0
2.93k stars 64 forks source link

OBS stream filter with libchafa #94

Open alavaelian opened 2 years ago

alavaelian commented 2 years ago

it is posible use libchafa to make stream in obs studio ? it would a very good way to make a impresive stream

hpjansson commented 2 years ago

Thanks for raising the question.

I don't know how OBS interfaces with OS streams/pipes specifically, but it might be possible. Unfortunately there isn't (yet) a ready-made tool for processing video streams with libchafa, but it wouldn't be hard to write one using e.g. ffmpeg or GStreamer for de/encoding. It's certainly fast enough.

This probably isn't exactly what you want, but there are a few hacky ways to record something from your screen and render it with Chafa:

One is by running an X virtual framebuffer (Xvfb) instance. This would be non-interactive, but I've used it successfully to transform xscreensaver and similar demos. Something like this (with the xscreensaver demos installed):

$ Xvfb :99 -ac -fbdir t -screen 0 1440x900x24 &
$ DISPLAY=:99 lament -root &
$ chafa --watch t/Xvfb_screen0

You could also record a session using any available tool (OBS, the GNOME screen recorder, etc) and use ffmpeg to split up the video file into individual images. XWD or GIF are the fastest options for this. Then use chafa to render the images in order:

$ chafa -d 0.05 --clear image*

I'd gladly hear more about what you'd like to do (Picture-in-picture live streaming? Camera/screen capture -> Chafa -> video stream?). Odds are it'll be supported at some point.

alavaelian commented 2 years ago

thanks for your answer picture in picture yes but only the web cam, the screen it would be good some times too

alavaelian commented 2 years ago

and thanks for your answer mate so much apreciated

hpjansson commented 2 years ago

It may be necessary to implement a Chafa-specific OBS filter.

Here's some inspiration (for me or whoever wants to do it) for how to do that in C sometime in the future: