Saturday, December 27, 2014

Play youtube audio from the command line on Raspberry Pi

mps-youtube allows you to play youtube content via a text terminal without needing X. As a result, without X, all you will get is audio. For me, I want to stream youtube audio to speakers, so this is one solution.

Install the latest Raspbian onto a SD card. If you are not familiar with how to do this, follow this guide.
I used Raspbian release 2014-12-24 for this guide.

1. Boot into the newly flashed Raspbian image.
2. Install python-pip by running the following command.
sudo apt-get install python3-pip
3. Install mps-youtube using pip by running the following command.
sudo pip3 install mps-youtube
4. Install youtube-dl
sudo pip3 install youtube-dl
5. Install omxplayer
sudo apt-get install omxplayer

1. Invoke mps-youtube by running the following command from a terminal.
2. Configure the audio player by running the following command.
set player omxplayer
3. Search for youtube content by running the following command.
/<search terms>
4. Select one of the results to play by typing the number.

If you do not hear audio, you should check the audio output of your raspberry pi.
Similarly, you should also test omxplayer.

Good luck.


Dan Hevey said...

Thank's for posting this. For some reason on my first install attempt, it complained that it couldn't find 'youtube_dl' and failed. I did 'sudo pip-3.2 install youtube_dl' and re-ran the install for mps-youtube, and it worked.

Anonymous said...

Dan, Your Comment Did help me, and Cheers for the post !

tsengf said...

Thanks Dan. I've updated the instructions.

lucas s said...

Still works in 2018!