I have a music script I’m working on that uses VLC as its backend for playing music in the background. However, I was looking around the MPV CLI arguments, and there’s quite a few things there that would work for my script.
However, I have a few issues with MPV before implementing this addition:
- I don’t want a window to appear whenever I launch MPV.
- I want MPV to remember certain properties, like volume.
- I don’t want the CLI info displaying in the terminal. This would cause issues as now MPV will close when the terminal closes. I need this to run in the background, like VLC.
I’ve kinda managed to solve 1. by using --no-vid, but I haven’t figured out 2. or 3. yet. Does anyone know any tips, tricks, arguments, etc. to get the desired experience I want with MPV?
It’s a Python program, so I am using subprocess currently.


Depends what operating system you’re using. I run Linux (Mint).
And I use mpv a lot… it’s probably the application I’m the most stupidly fond of, as a user I find it amazingly good.
I use it mostly through the Nemo file explorer (through its custom actions) as my video/music music player. But I also use it to listen to podcasts, using newsboat as my feed aggregator and yt-dlp to actually download/stream whatever multimedia content I want mpv to play. And, well, for everything else that contains video and/or audio.
You can launch mpv with
--no-videoand no window will be displayed, say if you want to play only the audio from a video file. You can also launch it using thesave-position-on-quit. I’ve mine set by default to yes (in mpv.conf), so it remembers position in whatever I play next time I play it, and on specific scripts/occasions it is set to ‘no’ (see example below).in my
~/.config.mpv/mpv.confI have setvolume=65which is the level I want it to start with, while defining custom keyboard shortcuts and mouse scrolling buttons to change volume in the~/.config.mpv/input.conf. I’ve never tried it but you might be able to add a volume parameter each time you launch mpv (maybe store the actual value in a hidden text file somewhere for it to load from, using a script?)Your 3, I’m not sure to understand what you want to do. But in order to keep mpv open after it’s done playing whatever, add this to your mpv.conf:
keep-open=yesAs an example, here is one of the ‘Nemo Actions’ I use to make mpv randomly play audio (even from video) from the folder I right-click on, without mpv opening any window. If you don’t know them already, custom Nemo Actions must be saved in
~/.local/share/nemo/some-file-name.nemo_action:[Nemo Action] Active=true Name=MPV shuffle NOVID Comment=Play at random the content of selected folder into mpv AUDIO only, no position save Exec=sh -c "mpv --no-video --save-position-on-quit=no --shuffle %F" Icon-Name=multimedia-video-player Selection=any Extensions=anyThe ‘exec’ part of that action uses standards mpv parameters next to Nemo’s own stuff.
I also use the socat utility that lets me connect a series of tiny (they’re one-liners) custom shell scripts directly to mpv, using system-wide keyboard shortcuts. I’m really not an expert about any of that, I just learned to use it to get what I wanted out of it which is a … universal mpv remote-control.
I don’t mean just the Play/Pause buttons but almost any of the controls I need with mpv.
For example, I started using it to let me skip forward/backward a couple seconds and resume playback while I’m listening to audio notes, as I recently started using a pocket voice recorder. Which makes mpv great when I’m transcribing said notes. Not as good but quite close to one of those dedicated old-school foot pedal people into that kind of tech used to use in the 80s and 90s… Yep, don’t tell anyone but I’m that old that I remember them ;)
Edit: I hope any of that can help you with your script.
I’m targeting a Linux release
I don’t want the active MPV file info in the terminal as if I CTRL+C, CTRL+D, or close the terminal, MPV will close too. So I want it to run as a background process (like how you can minimize VLC to the tray)
I don’t know if using something like
nohup mpv <some file> &would work. I guess I could usepkill mpvto close it then.I saw mpv has a
--quietoption. What does that do?