How to show playback time and duration in mpv terminal?
Customizing the terminal status line in mpv allows you to view the
exact playback time and total file duration directly from your
command-line interface. By modifying the terminal string format using
the --term-status-msg option, you can completely overwrite
the default status readout to show real-time progress, time elapsed, and
total length. This article covers how to configure this layout
temporarily for a single session or permanently across all media
playback.
Using Command-Line Flags
To test or apply custom terminal output styles for a single file, use
the --term-status-msg property when running the media
player from your terminal emulator.
The properties ${playback-time} and
${duration} represent the current timestamp and total track
duration, respectively. Execute the following command in your
terminal:
mpv --term-status-msg="Time: ${playback-time} / ${duration}" video.mp4This updates your active terminal line dynamically while the media streams, showing the formatted playback track time against the length of the container.
Configuring Permanent Terminal Status Displays
To avoid passing the command-line flag every time you open a media stream, you can save this configuration to your local configuration files.
- Open your
mpv.conffile using a standard text editor. Depending on your operating system environment, this file is typically located at:
- Linux/macOS:
~/.config/mpv/mpv.conf - Windows:
%APPDATA%\mpv\mpv.confor inside your portable installation directory.
- Append the status message definition directly into the configuration text file:
# Custom terminal status display
term-status-msg="Playback: ${playback-time} / ${duration}"- Save the changes and close the document.
Expanding Your Terminal Status Property Layouts
The configuration engine supports additional properties if you want more telemetry information on your command line alongside basic time indicators.
The table below outlines common string parameters that can be integrated into your custom status configuration syntax:
| Property String | Variable Output Description |
|---|---|
${playback-time} |
Current playback position format (HH:MM:SS) |
${duration} |
Total video or audio asset length |
${percent-pos}% |
Progress tracking calculated in percentages |
${playtime-remaining} |
Time countdown left until the media completes |