The logbook below is just that, a log of notes as I use and work on mpvc-tui. Entries are chronologically ordered with oldest first, and, attempt to be self-contained focused on a certain functionality/topic, to the extent that it is possible.
What got me started on using mpvc is being able to play URLs. This is the cause to start writing what you are reading now (this repo at https://github.com/gmt4/mpvc/). As in
mpvc add https://kuplasound.bandcamp.com/album/mirage/
One thing that bothers me when using mpvc, is that most programs performing ipc on mpv socket, just leave the socket at /tmp/mpvsocket
. A better default location for the mpv socket is $HOME/.config/mpvc/mpvsocket
.
A thing that I'd like to be able to do is to perform mpvc load/save
of the playlist, and, be able of manipulating the playlist using standard Unix commands eg. grep. The easiest way that comes to mind, is something a la: mpvc save | grep -v artist | mpvc load
, this enables to filter out an artist, and drop all the songs by this artist.
One particular feature where improvement could be done mpvc -a audio.opus, when mpv finishes playing audio.opus, mpv terminates, and, the current playlist is lost. This happens as mpv is started with --idle=once. A solution for this is to start mpv separately with --idle=yes. A shortcut for this is to run `mpvc --mpv` that does exactly this, after this the mpv instance can be manipulated with mpvc, and does not terminate once mpv finishes playing.
One thing I keep doing a lot, is typing mpvc status and mpvc -i, to check the mpv playlist and status. To this end I've quickly hacked a minimal TUI named mpvc-tui
, that continuously shows the mpvc playlist and status. In addition, while in mpvc-tui you can Control+C, to get a mpvc prompt to run quick mpvc commands, like: prev, next, pause, toggle, seek, volume, etc.
As explained above, mpvc-tui does three things: 1) display status, 2) display playlist, 3) prompt the user for interaction. Once we hit Control+C, and land on the user prompt, the following can be done:
When using the mpvc-tui prompt for some time, one notices that there's a lot of repetition of commands. To address repetition, one solution is to use a history file of past commands, and completion of commands and filenames. This can be achieved using `rlwrap(1)` in one shot mode that becomes a life-saver. Now, you get a more comfortable prompt, where TAB completion works on commands and filenames, as well as Control+R to repeat previous commands in the history file.
Another nifty detail of mpvc-tui, is that it can be quickly spawn from the WM launcher by using mpvc-tui -x
, then type a few mpvc commands to setup music, and close it. Or it can be started on the current terminal with `mpvc-tui` and left running as a long running program, and get back to it when needed.
When using `mpc(1)`, playlists can be managed using the mpc load/save/lsplaylists commands. In addition to load/save, mpvc adds the autoload/autosave commands:
mpvc autosave
: save the current playlist to $XDG_CONFIG_HOME/mpvc/playlist/.
If no arguments are provided the current playlist is named "$(date -Imin)".
Otherwise, if a name is given "mpvc autosave ambient.m3u", then the file is saved as "ambient.m3u"
mpvc autoload
: loads the named playlist from $XDG_CONFIG_HOME/mpvc/playlist/.mpvc lsplaylists
: list the playlists under $XDG_CONFIG_HOME/mpvc/playlist/.The above enables to arrange a playlist, and once we are happy with it, save it with `mpvc autosave playlist.m3u`, later, we can replay it again with: `mpvc autoload playlist.m3u`.
While using mpvc-tui
, one ends up wanting to configure the minimal look and feel that mpvc-tui provides. To this end the file mpvc-tui.conf
under $XDG_CONFIG_HOME/mpvc/ provides a place to overwrite the look and feel default settings of mpvc-tui.
We are on "Show HN"! https://news.ycombinator.com/item?id=34013149
That one is easy, for that purpose mpvc cmd args
sends the { "command": args }
to the JSON IPC. Some usage examples to test are:
mpvc cmd show-text "hello-world" 2000
mpvc cmd af toggle lavfi=[loudnorm=I=-16:TP=-3:LRA=4]
mpvc cmd af toggle lavfi=[dynaudnorm=g=5:f=250:r=0.9:p=0.5]
Note, audio filter commands above are lifted from https://github.com/mpv-player/mpv/issues/6210.
Mpv already plays URLs (both video and audio) from streaming platforms as youtube. So the one thing missing is to be able to search, select, and enqueue music from these services. This is provided by mpvc-fzf -s/-p, that does:
mpvc-fzf -s rolling stones
: Search and return the list of URLs found.mpvc-fzf -s rolling stones | fzf -m
: Search, Select and return the list of URLs selected.mpvc-fzf -s rolling stones | fzf -m | awk '{print $1}' | mpvc load
: Search, Select, Enqueue and play the list of URLs selected.mpvc-fzf -p rolling stones
: Is a shortcut of the last command that does the whole thing.Mpv IPC JSON socket allows receiving the media events generated by the running mpv instance. Subscribing to the mpv events can be done using the command: mpvc idleloop, by default events appear on standard output for a separate program to consume and react them. Some usage examples of the above are:
mpvc idleloop
: send the mpv events to stdout.mpvc idleloop | awk '/playback-restart/ {print}'
: select only the "playback-restart" mpv events.mpvc idleloop | awk '/playback-restart/ {system("notify-send -u normal -i dialog-warning \"$(mpvc)\"");print}'
: Send a notification when the track changes.I discovered fzf while adding support for selecting and playing YT videos #logbook-20221219, so I'm quite a newbie on fzf. Still I've been playing with fzf+mpvc to get them working together. So far I've focused on 3 points:
mpvc-fzf -p
: For searching/playing Internet media from YouTube.mpvc-fzf -l
: For searching/playing Local media from your file-system.mpvc-fzf -f
: For managing the mpv status and playlist: say mpvc play, pause, seek etc.This is still on a very preliminary state, but it's amazing what fzf can do, and so far, seems to fit very well with mpvc.
Continuing on the topic of using fzf with mpv, I’ve decided to split the code into three scripts:
mpvc
: that provides the mpvc functionality.extras/mpvc-tui
: that provides the mpvc TUI functionality.extras/mpvc-fzf
: that provides the mpvc FZF functionality.
I think it’s clear/simpler this way, as the mpvc-tui was getting more and more fzf functionality, that was unrelated to the TUI. This breaks some things, as for example, uses of mpvc-tui -[lfFspP]
that now have become mpvc-fzf -[lfFspP]
.
mpvc -S ~/.config/mpvc/mpvsocket-new --mpv add /path/to/media
: Starts a new mpv
instance listening on mpvsocket-new
and adds media.mpvc socklist
: Lists all mpv sockets, including those that are inactive: without a mpv instance running.mpvc sockclean
: Clean inactive mpv sockets: without a mpv instance running.ssh -NL $HOME/.config/mpvc/mpvsocket0:$HOME/.config/mpvc/mpvsocket0 mediacenter
Note, the above command just "works", but probably has some rough edges, and can be improved.
mpvsocket0
is locally accessible and can be directly managed by mpvc, mpvc-fzf, mpvc-tui
. For example, running mpvc to start a randomly chosen track from the playlist:
mpvc -q play $(( $RANDOM % $(mpvc get playlist-count) )
)
mpvc cmd/sockcmd/repl/get/set/cycle
.
Something experimental I've been testing lately is using: mpvc stash
command to save the currently playing state, to be restored later. The commands implemented by mpvc stash [list|show|push|drop|apply]
are inspired by git-stash(1)
:
mpvc stash list
: Lists the currently mpvc stashes.mpvc stash show [name]
: Shows the contents of the mpvc stash named [name].mpvc stash push [name]
: Stashes the current mpvc state to [name].mpvc stash drop [name]
: Removes the mpvc stash named [name].mpvc stash apply [name]
: Applies the mpvc stash named [name].mpvc load/save
that only loads/saves the playlist, as mpvc stash
saves the current playing settings including: playlist-pos, playback-time, volume, mute, pause, etc.
together with the playlist.
A few things have been going on since last entry, some effort focused on getting a “decent” site (this HTML thing you’re reading right now @ gmt4.github.io/mpvc ) where its easy keep track of whats going on. This effort has :
Keep posted.
This entry introduces mpvc-equalizer a Linear Phase 15-Bands Equalizer for the CLI/shell based on the firequalizer15.lua mpv-script.
The basic operations that are available in mpvc-equalizer
are:
mpvc-equalizer preset
: Provides a set of basic equalizer presets ready to be loadedmpvc-equalizer reset/load/save
: To reset/load/save mpvc equalizer settingsmpvc-equalizer json/bars
: To query the equalizer settings as JSON or as CLI barsAn example of the `mpvc-equalizer` to set equalizer values for classical music:
mpvc-equalizer preset mpvc-equalizer preset classical | mpvc-equalizer load mpvc-equalizer bars mpvc-equalizer reset
Continuing with the topic of the previous post about mpvc-equalizer, one reason for starting mpvc, was to ease was to managing audio from the CLI. In that sense mpv integrates well with ffmpeg to apply AV filters. However you've to, either start mpv specifying the ffmpeg cli flags for the AV-filters, or add keyboard shortcuts into the input.conf to be triggedred during runtime.
Instead of that, for quickly testing combinations of filters, I was looking for something more CLI oriented: apply the filters using the MPV JSON IPC. That's what happens under the hood when a command `mpvc cmdr af ...` runs, for example:
# start adding a rubberband filter mpvc cmdr af add "@rubberband:lavfi=[rubberband=pitch=1:tempo=1]" # Change the AV filter is easy, rerun the command with the changes mpvc cmdr af add "@rubberband:lavfi=[rubberband=pitch=0.98:tempo=1]" # Removing the filter is as expected mpvc cmdr af remove "@rubberband:lavfi=[rubberband=pitch=0.98:tempo=1]" # Another option is toggling the AV filters on and off with mpvc cmdr af toggle "@rubberband:lavfi=[rubberband=pitch=0.98:tempo=1]" # The same goes for what filters are currently applied mpvc getr af | jq # Clearing all the AV filters currently applied mpvc setr af '' # Some cools filters are flanger mpvc cmdr af add "@flanger:lavfi=[flanger=delay=1]" # And audio echo mpvc cmdr af add "@aecho:lavfi=[aecho=in_gain=0.9:out_gain=0.9:delays=1:decays=0.9]"
Last-Modified: Friday, 02 June 2023 by gmt4 Powered by #HTML 🧡 💚 💙