Play a Video in the Ubuntu Command Line-Just for Fun

So yesterday, me and some geek friends were sitting and discussing the power of the Linux Terminal application. It boiled down to what is the most geekiest or Terminal-savvy thing we have ever done with our command line. A friend mentioned that he has played videos “in” the Terminal. If he had said ‘through’ the Terminal, it was not a big deal, but how he played them inside the Terminal is what intrigued us. It is the mplayer application he had used to do so; which only plays videos in ASCII format-so obviously they seem very low resolution and barely watchable. I tried the trick with various videos and came to the conclusion that only some animated cartoon movies could be watched and fairly interpreted in the Linux command line. Thus, this trick is not what you can rely on but try once in a while-just for fun.

In this article, we will explain how you can install the mplayer through your command line and then watch an .mp4 video through it.

We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system

Installing the mplayer utility

The real capability of the mplayer

The Mplayer, when used with its GUI variant insead of the CLI, has the following features:

Mplayer is a movie player for Linux  although  it runs on many other platforms and CPU architectures. It plays most MPEG/VOB, AVI, ASF/WMA/WMV, RM, QT/MOV/MP4, Ogg/OGM, MKV, VIVO, FLI, NuppelVideo, yuv4mpeg, FILM and RoQ files, supported by many native and binary codecs. You can watch VCD, SVCD, DVD, Blu-ray, 3ivx, DivX 3/4/5, WMV and even H.264 movies, too. MPlayer supports a wide range of video and audio output drivers. It works with X11, Xv, DGA, OpenGL, SVGAlib, fbdev, AAlib, libca‐ca, DirectFB, Quartz, Mac OS X CoreVideo, but you can also use GGI, SDL (and all their drivers), VESA (on every VESA-compatible card, even without X11), some low-level card-specific drivers (for Matrox, 3dfx and ATI) and some hardware MPEG decoder boards, such as the Siemens DVB, Hauppauge PVR (IVTV), DXR2 and DXR3/Hollywood+. Most of them support software or hardware scaling, so you can enjoy movies in fullscreen mode.

Mplayer Installation

The mplayer utility is easily available through the official Ubuntu repositories and can easily be installed through the command line using the apt-get command.

Open your Terminal application either through the system Application Launcher Search or through the Ctrl+Alt+T shortcut.

The next step is to update your system’s repository index through the following command:

$ sudo apt-get update

Update the package lists

This helps you in installing the latest available version of a software from the Internet. Please note that only an authorized user can add, remove and configure software on Ubuntu.

Now you are ready to install mplayer; you can do so by running the following command as sudo:

$ sudo apt-get install mplayer

Install Mplayer

The system might ask you the password for sudo and also provide you with a Y/n option to continue the installation. Enter Y and then hit enter; the software will be installed on your system. The process may, however, take some time depending on your Internet speed.

You can see all you can do with this application, and also verify that it is indeed installed on your system, through the following command:

$ man mplayer

Play Videos through the Mplayer

I will now explain how you can play a video saved to your system using the mplayer. This is the command syntax you can use:

$ mplayer -vo caca /location/of/file

The vo flag indicates that you want to play a video using the mplayer. The caca option means that you want to use the color text editor for displaying ASCII, thus playing a video in color. If you use the aa option instead, that would mean a black and white display which would be even sillier.

Here, I will be using the following command in order to play an mp4 video that resides in my /home/Videos/ directory:

$ mplayer -vo caca /home/Videos/SampleVideo.mp4

Here is what I could see in my Terminal:

Play Video on the Linux command line

All I could interpret was an animal coming out of a door or a hole? And, here is what the original video looks like:

Calling it “close enough” would be nothing short of exaggeration.

This, after all, was a fun trick and I would rather watch my videos through the UI using one of the modern video players available for Ubuntu.