@gmt4 mpvc logbook

Star Follow @gmt4 Download Watch Issue


Logbook Entries


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.

On playing URLs, 30 Mar 2022

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

On securing mpv socket location, 14 Nov 2022

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.

On load/save functionality, 18 Nov 2022

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.

On persistent mpv startup, 20 Nov 2022

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.

On a minimal mpvc-tui, 03 Dec 2022

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.

On using the mpvc-tui prompt, 13 Dec 2022

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:

  1. run mpvc commands starting with "mpvc". This allows for manipulating the mpv/mpvc status. The commands run with "mpvc" have QUIETFLAG=true set, to not clutter the mpvc-tui.
  2. run shell commands internally starting with "!". This allows for commands that manipulate mpvc-tui program, such as changing the working directory, with cd/pwd. This also allows for starting your favorite editor to configure the mpvc-tui look and feel with: "!$EDITOR $MPVC_CONFIG".
  3. run shell commands externally starting with "!!". This allows for running commands on a separate shell. This gives room for more complex commands, like starting alsamixer to manipulate audio levels, change outputs with `pactl(1)`, etc.
  4. quit the mpvc-tui, by typing quit, exit, or "q".

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.

On using the mpvc-tui -x launcher, 14 Dec 2022

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.

On managing playlists with mpvc autoload/autosave, 15 Dec 2022

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:

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`.

On customizing mpvc-tui look and feel, 16 Dec 2022

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.

Show HN: mpvc-tui – A minimal mpc-like CLI and TUI for controlling mpv, 16 Dec 2022

We are on "Show HN"! https://news.ycombinator.com/item?id=34013149

On issuing direct JSON IPC commands to mpv, 17 Dec 2022

That one is easy, for that purpose mpvc cmd args sends the { "command": args } to the JSON IPC. Some usage examples to test are:

Note, audio filter commands above are lifted from https://github.com/mpv-player/mpv/issues/6210.

On playing music from streaming services as youtube and co., 19 Dec 2022

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:

  1. Query the Invidious API and return a list of URLs
  2. Use fzf -m to select from the search results.
  3. Use mpvc load to enqueue the selected songs into the mpv playlist.
Some usage examples of the above are: Note, that you can use this command from inside mpvc-tui too, by hitting Control+C and then typing "!mpvc-fzf -p rolling stones"

On subscribing and receiving mpv events, 21 Dec 2022

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:

On using mpv together with the fzf fuzzy finder, 27 Dec 2022

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:

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.

On using mpv together with the fzf fuzzy finder, 12 Jan 2023

Continuing on the topic of using fzf with mpv, I’ve decided to split the code into three scripts:

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].

On controlling multiple remotely running mpv instances, 19 Jan 2023

A work in progress update, in no particular order, but, mostly focused on using mpvc to control a remote box (Raspberry Pi) acting as an audio/media center: This goes together with other related command as: mpvc cmd/sockcmd/repl/get/set/cycle.

On stashing mpv media player state to restore later, 19 Feb 2023

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):

This is different from 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.

CSS, RSS & casts updates on the gmt4.github.io/mpvc site, 31 Mar 2023

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.

Introducing mpvc-equalizer: a basic mpv equalizer for the CLI, 25 Apr 2023

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:

An 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

On applying ffmpeg AV filters using the MPV JSON IPC, 2 June 2023

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 🧡 💚 💙