12

I already found how to watch YouTube videos in terminal, in ASCII mode, but my goal is to watch them in a bash session, without opening a different window.

So, supposing I already have a tmux session, and I do:

$ watch-youtube <video-url>

I want to watch it there, in that tmux window/pane (split).

How can I do that?


Relevant output

$ mpv --vo help
Available video outputs:
  vdpau          : VDPAU with X11
  opengl         : Extended OpenGL Renderer
  xv             : X11/Xv
  sdl            : SDL 2.0 Renderer
  opengl-old     : OpenGL (legacy VO, may work better on older GPUs)
  vaapi          : VA API with X11
  x11            : X11 ( XImage/Shm )
  null           : Null video output
  image          : Write video frames to image files
  opengl-hq      : Extended OpenGL Renderer (high quality rendering preset)
  wayland        : Wayland SHM video output

1 Answers1

17

libcaca will display in your current terminal if $DISPLAY is not set. So you can do something like:

DISPLAY= mpv --quiet -vo caca 'https://www.youtube.com/watch?v=bvYgBty6nJs'

The same trick works with mplayer, though it doesn't (AFAIK) have integrated libquvi support, so you have to extract the video URL to pass it.

derobert
  • 109,670
  • 1
    Getting [vo] Video output caca not found! Error opening/initializing the selected video_out (-vo) device. -- only audio is working – Ionică Bizău Oct 09 '14 at 16:41
  • @IonicăBizău is your mpv built without libcaca? Check mpv --vo help and see if its there. I'm using mpv 0.6, by the way. – derobert Oct 09 '14 at 16:43
  • Probably? See the update. – Ionică Bizău Oct 09 '14 at 16:44
  • 1
    Yeah. So to use caca with mpv, you'd have to recompile it with caca support. Or use mplayer (if your mplayer has caca) as in the question you linked to. The key thing is that DISPLAY= part, to keep it from popping up a new window. – derobert Oct 09 '14 at 16:46
  • Really awesome stuff here. It's working with mplayer, however tmux becomes unusable when such a process is running. Is there any way how to fix this? – Ionică Bizău Oct 09 '14 at 16:55
  • @IonicăBizău Not sure. Works fine here in both screen and tmux... Though I'm on a fast machine. It does push the load average up to 2 or so when running mpv/caca in tmux... – derobert Oct 09 '14 at 17:04
  • I already have 5 tmux windows opened in the same terminal tab and maybe that's the thing... But even having just a split, it's very slow -- I mean, watching the video in the right side works fine, but in the left side I cannot do anything. I also have a powerful machine :-) Can you reproduce this with mplayer? – Ionică Bizău Oct 09 '14 at 17:14
  • 1
    @IonicăBizău I even tried starting three videos in three different panes (tried with both mpv and mplayer1); using bash in a fourth was still just fine. Maybe it's your terminal emulator collapsing? I'm using xterm. – derobert Oct 09 '14 at 17:23
  • The latest command (on Mac, at least) is mpv --vo=help – campeterson Sep 09 '21 at 22:20