mpg123
Play MPEG audio (MP3) files
TLDR
Play the specified mp3 files
Play the mp3 from stdin
Jump forward to the next song
Jump back to the beginning for the song
Stop or replay the current file
Fast forward
Quit
SYNOPSIS
mpg123 [options] file(s) | URL(s)
mpg123 -@ playlist_file [options]
PARAMETERS
-v
, --verbose
Increases the verbosity of output messages, showing more details about decoding and playback.-q
, --quiet
Suppresses most output messages, keeping the console clean during playback.-s
, --stdout
Writes raw PCM audio data to standard output instead of playing it through the sound device. Useful for piping to other tools.-w
<file>, --wav
<file>
Decodes the MP3 and writes the output to a WAV file specified by <file>.-o
<module>, --output
<module>
Specifies the audio output module (e.g., alsa, oss, pulseaudio, jack) to use for playback.-a
<device>, --audiodevice
<device>
Selects a specific audio device for output within the chosen module (e.g., hw:0,0 for ALSA).-Z
, --shuffle
Shuffles the playlist or provided files randomly before playback begins.-B
<size>, --buffer
<size>
Sets the output buffer size in kilobytes. Larger buffers can help prevent skips on slower systems or over networks.-l
<N>, --loop
<N>
Loops the entire playlist or single file <N> times. Use 0 for infinite loop.-@
<file>, --list
<file>
Reads a list of files or URLs to play from the specified <file>, with one path per line.--volume
<factor>
Sets the output volume. A factor of 100 means 100% volume; values above 100 amplify the sound.-t
, --test
Decodes the MP3 file without producing any audio output, useful for performance testing or validating files.
DESCRIPTION
mpg123 is a classic, lightweight, and fast command-line MP3 player for Unix-like operating systems. Developed initially by Michael Hipp, it was one of the first widely adopted console-based MP3 decoders and players. Its primary strength lies in its efficiency and minimal resource consumption, making it ideal for low-resource environments, servers, scripting, and embedded systems where a graphical interface is not required or desired.
mpg123 decodes MP3 audio streams and outputs them directly to the system's sound device, supporting various audio backends like ALSA, OSS, PulseAudio, and JACK. It can play local files, streams from URLs, and even raw PCM data to standard output for further processing. While it lacks the visual bells and whistles of modern GUI media players, its simplicity and robust performance have ensured its continued relevance among system administrators, developers, and users who prefer command-line tools for their reliability and scriptability. Recent developments have also brought features like gapless playback and improved streaming capabilities.
CAVEATS
mpg123 is a dedicated MP3 player; it does not support video playback or other multimedia formats like Ogg Vorbis (use ogg123 for that).
While highly efficient, its playback quality can be affected by the underlying audio system's configuration (e.g., ALSA or PulseAudio settings).
As a command-line tool, it offers no interactive graphical user interface for playlist management, visualizations, or complex audio effects.
EXIT STATUS
mpg123 exits with a status of 0 upon successful completion of playback or operation. A non-zero exit status indicates an error occurred (e.g., file not found, decoding error, audio device issue), which is highly useful for error handling in shell scripts.
USAGE IN SCRIPTS
Due to its command-line nature and predictable behavior, mpg123 is frequently used in shell scripts for background audio playback, system sound notifications, or as part of automated audio processing pipelines. Its -s
(--stdout
) option is particularly useful for piping decoded audio to other tools like sox for format conversion or manipulation.
HISTORY
mpg123 originated in the late 1990s, developed by Michael Hipp, quickly becoming a staple in the Unix/Linux world due to its groundbreaking ability to play MP3s from the command line efficiently. At a time when computing resources were often limited, its minimal footprint and speed were significant advantages, establishing it as a go-to solution for lightweight audio playback.
After a period of reduced activity, the project was revitalized by a new development team, ensuring its continued maintenance and evolution. This revival brought modern features like gapless playback, improved streaming support, and broader compatibility with various audio backends, solidifying its place as a reliable and widely used tool for audio playback in scripting, servers, and embedded environments.