On Linux, a great way to play video files with the terminal. Going this route means you bypass all of the fancy UI elements in favor of simplicity. Introducing Mplayer, it’s a powerful command-line based video player that you can use to play video from the Terminal. It supports many different media formats, and works very well on computers that are low on RAM.
Before using Mplayer, you’ll need to install it on your PC. Follow the instructions below next to your Linux distribution. Keep in mind that you’ll need to be running Ubuntu, Debian, Arch Linux, Fedora, or OpenSUSE.
sudo apt install mplayer
sudo apt-get install mplayer
sudo pacman -S mplayer
sudo dnf install mplayer
sudo dnf install mplayer
Build From Source
Need to build Mplayer from source? To do so, you’ll need to first install a couple packages. These packages are important for the build process. Open up your package manager, search for “build-essential”, “subversion”, “check install”, “yasm”, “dockbook-xml”, “git”, “xsltproc” and “libxm2-utils”.
Note: If you can’t find these dependencies on your version of Linux, consider looking at the official Mplayer website for guidance.
When all the dependencies are taken care of, download the latest version of the source code.
Run configure. The configure script will scan your Linux PC and prepare it for the build process.
Next, use the make command to compile the source code.
Install the program with:
make install Each time there is a Mplayer update you'll need to re-run the building process. For more information on compiling Mplayer from source, check the website.
The Mplayer tool is simple yet powerful. It’s a command-line based app, so to interact with it you’ll need to open up a terminal window. Inside the terminal, use ls to view the /home/ directory. Home is the basis for most files stored on a Linux PC so this is a good place to start. In this tutorial, we’ll assume video files are in /home/username/Videos/.
Ls reveals that there is a “Video” folder. The next step is to use the CD command to change working directories.
Moving the terminal into Videos only makes it so that the terminal works from that directory. You’ll need to run ls again to view the names of video files.
Mplayer works with nearly every video codec on Linux, as it makes heavy use of the FFmpeg encoding tool. Use the mouse to highlight the name of the video files. Alternatively, pipe all of the video file names to a text file.
ls > video-files.txt
Open up video-files.txt in Gedit (or whatever GUI text editor tool you use on Linux).
Now that you’ve got a list of file-names, use the mplayer command to playback a file. Here are some playback examples to follow.
or, play multiple files with:
mplayer video1.mp4 video2.avi video3.3gp
Running a basic playback command (like above) opens up a GUI window and instantly starts the video. To quit the video, close the window. Alternatively, the player can be quit by pressing “Q” on the keyboard.
MPlayer Keyboard Shortcuts
Given that Mplayer is primarily command-oriented, it relies heavily on shortcuts. If you’re new to using a program like Mplayer, follow along with the post to get acclimated.
To skip through a video (back or forward), use left or right arrow keys. Up and down arrow keys also skip back and forward in the video playback. Pressing space on the keyboard pauses playback, and f switches Mplayer to full-screen mode. Additionally, users can skip between files by pressing < and >. The < goes left in the playlist, and > goes right.
Mplayer has several different audio settings. To control the volume levels for playing videos, use 0 and 9. The number 9 in the number row decreases volume, and the 0 increases it. To mute things altogether, press m. Need to switch between audio tracks? Hit the # key.
The Mplayer video tool has pretty good audio balance control. Users can shift the balance around (left and right) easily with the press of a button. To shift the balance of the audio in a video to the left, press Shift + ( to move left, and Shift + ) to move right.
The Mplayer video tool has a few video-specific settings. These settings pertain to the contrast, hue, saturation, framerate, and brightness of the video. To manipulate the contrast levels in Mplayer, use 1 and 2. The 1 key decreases contrast, while 2 increases it.
Brightness, hue, and saturation work roughly in the same way, and have shortcuts on the number row as well. Change brightness levels in Mplayer with 3 and 4, hue levels with 5 and 6, and saturation with 7 and 8.
Along with the visual settings covered above, the user can change “frame drop” settings in Mplayer by pressing d.
Subtitles are important in video playback, especially for users that lack the ability to hear. As usual, with Mplayer, everything is done by shortcut. To view subtitles on any given video, press the v key. If a video file supports multiple subtitle tracks, switch between them with j.
The y button tells Mplayer to skip forward in the subtitle line, while g moves backward.
Users also have control over the subtitle delay. To add a +0.1 second delay to subtitles in Mplayer, press the x button. Decrease the delay (-0.1 sec) with z.