Have you ever played or streamed sound controlled in a command line? I myself play & stream every sound controlled through command line interface. To achieve that I use an odroid c2 connected to my av-receiver.
That’s how you control your streaming – no GUI, no video and no diversion:
0: Application – Setup:
- OpenSSH
- screen: window managing
- mps-youtube: YouTube Streaming
- youtube_dl: YouTube Download Tool
- mplayer: a movie/audio player
- cmus: console music player
- mp3blaster: text based mp3 player
- rsync: fast incremental file transfer
- ffmpeg: record, convert and stream audio and video
1: Get the odroid ready:
- Download the current Ubuntu 16.04LTS Mate Image from here
- Flash the image on a SDcard or an eMMC-module according to this instructions.
Warning:
Don’t update your Ubuntu installation – in my case it produced swapping and memory errors during boot after some reboots – I hope it will be better in the future.
2: Install mps-youtube and more:
- Install Python3(Ubuntu)
sudo apt-get install python3
- Install pip3 (pyton package system)
wget https://bootstrap.pypa.io/get-pip.py python get-pip.py
- Install mps-youtube & youtube_dl
[sudo] pip3 install mps-youtube [sudo] pip3 install youtube_dl
- Install mplayer
sudo apt-get install mplayer
- Install ffmpeg
sudo apt-get install ffmpeg
3: Terminal – SSH – screen – issue:
In my case the the streaming stopped after some time randomly in the ssh session and I haven’t figured out jet why, because mplayer was still running. Only the mps-youtube gui stopped updating the status from the mplayer stream. I tried using screen, background running with command to process and more but it always stopped playing randomly.
Solution: if you start a screen session on logon within your GUI terminal it looked like the problem will not occur. So something must be different if you create a screen session with in a ssh-session or within a GUI-terminal. In my case I have MATE-Terminal.
Do a automatic GUI logon on boot and afterwards run automated a script insight your GUI-terminal or start directly “screen” in your terminal. I prefer the script version because I will add some other features in future.
-e, --command Execute the argument to this option inside the terminal
But after all, sometimes it looks like if the python mps-youtube application has some bugs and stops updating and finally crashes after some time.
First try:
Now you are able to run “mpsyt” insight the existing screen session. If you are accessing your system over ssh you can attach the screen session with “screen -rd”.
List all screen sessions with “screen -ls”.
Mpsyt is very easy to use: “/xxx” for search, “1-12” will play the first 12 listed songs.
4: Setting up mps-youtube:
Customizing the result list:
set columns user:14 date category:9
To download audios or videos from YouTube we have to set some more settings insight mps-youtube.
set encoder 1 {1 = MP3 256k} set audio_format m4a set ddir <download direcory>
This configuration will enable you to download audios and automatically converting them to MP3. You need youtube_dl and ffmpeg installed on your system.
Have a look at the possibly commands (“h” or “help“) for additional information’s and how to use the player.
5: Making SSH easy to use with SSH-Keys:
We will need this for the audio synchronization later. If you don’t want to type the password every time you synchronize the audios.
- Generate a SSH-RSA key pair
ssh-keygen -t rsa
- Copy the SSH-Key to your media system
ssh-copy-id user@xxx.xxx.xxx.xxx
- Login to your media system without using the password
- Repeat this with all your devices which you want to use to download
More informations and a nice How-To are available at digitalocean.
6: Sync the downloaded audios to a device:
For that, you must have installed “rsync” on both system. Using rsync for syncing two directories.
rsync -Pav user@xxx.xxx.xxx.xxx: <download direcory> Music/sync
Info: I have a rooted Android phone and so i can sync the audios with the same command because Android has “ssh-keygen” + “ssh” + “rsync” onboard. 🙂
7: Play audios from local directory with a command line player:
In my case I use cmus and mp3blaster. Both are more or less easy to use and are doing the job well.
Have fun with your command line audio system 😀