Playing music/audio on command-line

Audio files
I use the play(1) command available from audio/sox (under LGPL) to play music/audio on the terminal console. Sometimes, I'll use the speed argument to slow down songs.

audio/vorbis-tools has ogg123(1), which is pretty good for playing ogg music files. audio/flac123 wasn't able to play flac24 bit files. The play command from sox covers these music formats and specifications. Just have to be careful to not use the sox command to permanently edit files, I meant to play.

There are a few console and curses based mp3 players in ports under the audio category.

Streaming
In the past, I've used multimedia/shell-fm (for CLI) to play streaming music from last.fm, but this port has been depreciated. It had an extensive library of commercially available music. Just tried audio/somafm-cli (under MIT license) which plays music from SomaFM, and this may be my go to: /usr/local/share/doc/soma-cli/README.md. SomaFM has commercial-free indie and underground music: https://somafm.com/about/index.html.

somafm ls|grep -i electr
somafm play specials --quality=highest
somafm.jpg


Optical disks
There are curses players for CDs too. It reminds me of playing CD's on my PC in the 90's on MsDos. The curses interface has a nostalgic value. Burning them to flac for CD quality (16bit, 44.1kHz) may be more convenient. Audio from DVD has a higher quality: also applicable in the case of using the audio from commonly available video DVDs for music.


More
What do you use to play audio/music on the terminal/console, including through curses? What can you describe about its benefits or how you've used it? What set it apart from other command line audio players? How about screenshots of curses or CLI music players.
 
mpv(1)
plays all standard music, and video formats, uncomplicated playlists (no XML-BS, just a simple textfile with the filenames)
Besides VLC (which also provides CLI usage) I use for a very few special things, only, it's my one and only mediaplayer.
 
ffmpeg -i mymusicvid.mp4 -vn audioonly.mp4
With ffmpeg you can get the sound out of a video, and produce an audio only file directly without the need of the .mp4 format again. Simple:
ffmpeg -i videofile.mp4 audiofile.mp3

I don't know, if mp3 is a better choice than mp4 (size). To me it's also to distinguish files by their extensions. To me a .mp4 is a video but no audio file. As far as I know ffmpeg cannot directly produce .ogg, at least not by simply autodetecting it by the target file's extension. But mp3 suffices my needs (I don't care if it's 'old'. it works, does the job; and can be converted again, if needed.)
 
That's a good point, making it easier to distinguish, and in my earlier post, I actually thought of of making it audioonly.mp3, but got lazy, and thought if I did that, I should explain why, etc., etc. TLDR: I'm lazy.
 
+1 for mplayer
As far as I know mplayer is the base for several other players, like mpv, for which again there are many other players based on, including several ones with a GUI.

Like many others my first media player I really felt in love with was WinAmp (Windows). After that it became VLC. Then I learned I don't need, and I don't want no GUI anymore.
GUIs have a big disadvantage:
You either have a very limited choice of options/features (prechosen by others), or you get a too complex, confusing, hard to use UI.

That's why I stopped VLC to be my #1 mediaplayer: It became too complex, came with too many features I simply don't have no use for. Yes, mplayer and mpv come with way more features.
But that's the benefit of using CLI tools: I only need to care about what I need/want.
 
I'm lazy.
That's okay.
Crucial point is as long as you know which file is what, and you don't lose overview everything is fine.

For several videos I also have a sound only version. There a many movies (the better ones, not that plotless pot shooting action BS) worth just to listen to, or for usage on my mp3-player, e.g. for learning foreign languages.
For that I need to distinguish which one is the movie, which one is the audio.
So, better have a pure audio file for it in the first place (less size than video files), and give them the right own extension.

I'm lazy, too. I don't like to clean up. But I like to have things clean, and in order.
That's why I keep my files in pretty clear order (- trying to :cool:.)
I seldom use find on my files, because I know what I have, and where it is - at least where to look for.
At least once a week I manually scan and clean up my ~
Since I learned: cleaning up regulary produces many, but small, tiny cleaning jobs, which prevent me from large cleaning challenges, which are being postponed, grow larger, feel worse...
Worst case (own experience from my youth, too):
Having a mess you don't find your files within all the junk not cleaned up, even find and grep are of no real help anymore, is pretty much similar as the files were removed.

So, if I stumble over a file which ain't clear to me I get sniper eyes, examine it, and move (rename) or remove it immediatly. I hate files named 'untitled' or 'test' (happens to me, too 😁)
 
You're making me feel guilty. Well, a few weeks ago I removed about 100 old files, the type of thing where I just made a quick text file and had just left it after using. I should be more like you. I could go off on a complete tangent here, about how backing up some anime and how I got confused, but it's not funny enough to take everyone's time.
 
You're making me feel guilty.
Oh no, no, no! I didn't meant that.
As I said: If your way works for you everything is fine - your machine, your rules!

I was a slob until my mid twenties. Not as bad as Oscar from "The Odd Couple", but kind of. Single man household. But if mommy doesn't come and clean up, it's a good school for life. Men learn to pee sitting down when they need to clean up themselves.
It pisses me to live in a dump - my own mess.
Once I realized two things:
1. No work can be spared. All shit needs to be cleaned up sooner or later anyway.
2. So, better sooner. Don't postpone it. Do it directly.
It just needs a bit more discipline for the start, until it becomes an automatic habit (~ three weeks we need to (un)train habits), but I learned a third thing this way:
In the grand total it's even less work that way.
Plus not having a to-do-list of "giant clean up projects", postponed for months(years), nagging on your mind, makes you feel a lot better.

For sure I did not became Felix from "The Odd Couple" (this guy has issues), but I already start to clean up my kitchen while I'm waiting for things cooking, clean up my desktop, my directories, delete temp files etc. everytime a job is done, before I start another one. It needs to be done anyway.
In several ways the basic core tools in Unix help on that: (sub)directories, filenames long enough for comprehensible names (give a file a good name immediately, don't postpone this is almost half the job done), mv, rm(!),... scripts (e.g. in my ~/latex/ I have a most primitive script removing all .aux, .log, .out files), and many other things.
But we are back again, where I started:
That's something everybody has to figure out, and define for herself:
your machine, your rules
 
audio/somafm-cli uses mpv(1) in the background, as it can be seen with the ps|grep soma:
Code:
/usr/local/bin/bash /usr/local/bin/somafm play digitalis
mpv --no-config https://API.somafm.com/digitalis64.pls
That this relied on mpv made me wonder about streaming other channels with mpv through a shell or python script. /usr/local/bin/somafm is a bash script. This can be seen from output of the ps command above and through less /usr/local/bin/somafm.

multimedia/mpv is on the dependency list of somafm, as can be seen with pkg info -d somafm-cli.

Somafm can be played in the background. However, playing it this way, it quits after one song, as the mpv entry disappears from ps(1). play from sox can't play in the background at all.
 
Back
Top