In this chapter, we’ll explore how to handle multimedia files (audio, video, and images) directly from the command line. You’ll learn how to play, edit, and convert multimedia files using powerful tools like ffmpeg, mpv, and imagemagick. By the end of this chapter, you’ll be able to manage multimedia files efficiently without relying on graphical applications.


1. Why Learn Multimedia in the Command Line?

Command-line multimedia tools are:
Lightweight: They consume fewer resources compared to graphical applications.
Powerful: They offer advanced features for editing, converting, and processing multimedia files.
Automation-Friendly: They can be scripted for batch processing and automation.
Remote Work: They are ideal for managing multimedia files on remote servers or headless systems.


2. Playing Audio and Video

Using mpv

mpv is a versatile media player that supports a wide range of audio and video formats.

Using mplayer

mplayer is another popular command-line media player.


3. Editing and Converting Multimedia

Using ffmpeg

ffmpeg is a powerful tool for editing, converting, and processing multimedia files.

Using imagemagick

imagemagick is a suite of tools for editing and converting images.


4. Working with Images

Viewing Images

Use feh to view images from the command line.

Creating Image Slideshows

Use feh to create a slideshow of images:

$ feh -D 5 -F -Z /path/to/images/

5. Practical Examples

Batch Convert Images

Convert all .png files in a directory to .jpg:

$ for file in *.png; do convert "$file" "${file%.png}.jpg"; done

Extract Audio from Multiple Videos

Extract audio from all .mp4 files in a directory:

$ for file in *.mp4; do ffmpeg -i "$file" -q:a 0 -map a "${file%.mp4}.mp3"; done

Create a Video Slideshow

Combine images into a video slideshow using ffmpeg:

$ ffmpeg -framerate 1 -i image%d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p slideshow.mp4

6. Practice Time!

Let’s put your new skills to the test:
1. Use mpv to play a video file and adjust playback speed.
2. Convert a .mp4 video to .avi using ffmpeg.
3. Resize an image to 50% of its original size using imagemagick.
4. Create a slideshow of images using feh.


Command-line multimedia tools like ffmpeg, mpv, and imagemagick are powerful and versatile, allowing you to handle audio, video, and images efficiently. By mastering these tools, you can streamline your multimedia workflows, automate repetitive tasks, and manage files effectively without relying on graphical applications.