osx - Playing youtube videos in terminal as text using mpv or mplayer with libcaca or aalib?
Asked Answered
F

3

7

I installed via homebrew:

brew install mplayer mpv libcaca aalib

to try to play videos as text in my terminal. Using mplayer, I tried aa:

youtube-dl https://www.youtube.com/watch?v=urxk4mveLCw -o - | mplayer -cache 64000 -vo aa -

and also caca:

youtube-dl https://www.youtube.com/watch?v=urxk4mveLCw -o - | CACA_DRIVER=ncurses mplayer -cache 64000 -vo caca -

however, both give the following error:

Error opening/initializing the selected video_out (-vo) device.

Trying again with mpv:

mpv "http://www.youtube.com/watch?v=OC83NA5tAGE" -vo caca
mpv "http://www.youtube.com/watch?v=OC83NA5tAGE" -vo aa

Which outputs:

09:00 $ mpv "http://www.youtube.com/watch?v=OC83NA5tAGE" -vo aalib
Playing: http://www.youtube.com/watch?v=OC83NA5tAGE
 (+) Video --vid=1 (*) (h264)
 (+) Audio --aid=1 --alang=eng (*) 'DASH audio' (opus) (external)
[vo] Video output aalib not found!
Error opening/initializing the selected video_out (-vo) device.
Video: no video

Exiting... (Errors when loading file)
✘-2 ~

When looking at the man page for mpv, I find:

   caca   Color  ASCII art video output driver that works on a text console.

          NOTE:
             This driver is a joke.

What am I doing wrong, and how can I correctly watch the youtube videos in the terminal?

Thanks.

P.S If it makes a difference, here is my screenfetch information:

OS: 64bit Mac OS X 10.9.5 13F1603
Kernel: x86_64 Darwin 13.4.0
DE: Aqua
WM: Quartz Compositor
WM Theme: Blue
GPU: Intel Iris

Also I am using iterm2 as my terminal, but I also have xterm via xquartz, and the normal terminal.

Foison answered 5/7, 2016 at 13:8 Comment(0)
C
17

caca is not installed with mpv by default, you will need to set it as an option flag.

You can reinstall this with caca with

brew reinstall mpv --with-libcaca

or if you are installing from fresh

brew install mpv --with-libcaca

Now running

mpv --vo=help

Outputs the following

Available video outputs:
  opengl         : Extended OpenGL Renderer
  null           : Null video output
  image          : Write video frames to image files
  caca           : libcaca
  opengl-hq      : Extended OpenGL Renderer (high quality rendering preset)

So you can see that caca is now available to be used. Then simply run your command to play your chosen video in terminal.

mpv "http://www.youtube.com/watch?v=OC83NA5tAGE" -vo caca
Cephalometer answered 13/7, 2016 at 15:18 Comment(2)
Yup it worked perfectly, except I needed the -ytdl flag. Thanks!!Foison
no luck: Error: invalid option: --with-libcacaErmina
U
3

I think you don't have caca/aa driver compiled in mpv/mplayer; check:

mpv --vo=help
mplayer --vo=help

if they don't list caca, you should try to compile mpv (or mplayer) from source.

Uneasy answered 10/7, 2016 at 23:25 Comment(0)
C
1

This answer was up there in Google's results for playing YouTube videos but only audio. In 2024, it seems libcaca isn't necessary. The option to play without video is already built-in via the "null" video output:

mpv --vo=help
Available video outputs:
  libmpv           render API for libmpv
  gpu              Shader-based GPU Renderer
  gpu-next         Video output based on libplacebo
  null             Null video output
  image            Write video frames to image files
  tct              true-color terminals
  kitty            Kitty terminal graphics protocol

So just do

mpv "https://www.youtube.com/watch?v=e-2TaN77gD4" -vo null
Counteroffensive answered 11/3 at 10:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.