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.

Prerequisites:
Install the latest Raspbian onto a SD card. If you are not familiar with how to do this, follow this guide.
http://www.raspberrypi.org/documentation/installation/installing-images/
I used Raspbian release 2014-12-24 for this guide.

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

Running:
1. Invoke mps-youtube by running the following command from a terminal.
mpsyt
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.

Notes:
If you do not hear audio, you should check the audio output of your raspberry pi.
http://www.raspberrypi.org/documentation/configuration/audio-config.md
Similarly, you should also test omxplayer.
http://www.raspberrypi.org/documentation/usage/audio/

Good luck.

3 comments:

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.

rakeshmadupu said...

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

tsengf said...

Thanks Dan. I've updated the instructions.