Raspberry Pi Basics: Part II-Audio/Video
Posted by Beyond
Okay! so here I am again with a little more on RaspberryPi (~RasPi). In last blog post, we discussed about the basic GPIO usage of the Raspi. I think that I tried to explain the GPIO quite well. (lolz.. self-praise). Yeah, I know its late since my last post and there is quite a few days gap. I do have a strong reason for this, I was actually LOST out watching HOMELAND and BREAKING BAD!! Nevertheless, I finished them watching. :p
Also, I have written down three most posts on RasPi and will publish all along. Sort of basic tutorial Series for RasPi.
So, as said this post is all about Audio and Video in RasPi.
I am running Debian Wheezy to work on Raspi, so most of the things will work ‘out of the box’ by the use of the almighty *package manager*. Just do a `apt-get install **’ and you are done. Daaaaaaaahh, you actually managed to run the application on the RasPi.
First of all make sure, you are updated by the following
- sudo apt-get update
- sudo apt-get upgrade
Making the sound work!
First check whether the sound module is loaded or not by use of ‘lsmod’ command. You may get something like “snd-bcm**” if your module is loaded. Otherwise you have to load it via the following commands but first get the root shell.
- sudo su –
Now at the root shell, just append the sound modules to /etc/modules
- echo ‘snd-bcm2835’ >> /etc/modules
exit the shell and come back to user Pi, and load the module
- sudo modprobe snd-bcm2835
Since we have loaded the module, we are left with the soundserver and the drivers ‘ALSA’, after that your sound should be working!
Testing the sound is really simple: you all need is to atleast have the player to play your sound file. One can have Totem, VLC or mplayer. I prefer VLC everywhere.
- sudo apt-get install mplayer alsa-base alsa-utils pulseaudio mpg123
that installed mplayer, mpg123 and alsa, pulseaudio all in a single time. Do download the VLC media player too, because I did all the work on it ( lolzzz)
- sudo apt-get install vlc
Do all of this and have a reboot.
- sudo reboot
Now simply test the audio file with vlc media player
- cvlc /path/to/myaudiofie.mp3
and you should be listening to the audio.
VLC media player does most of the work for you, it plays smaller and not very high quality videos for you for free! But for high quality you have to convert them to match our needs using ffmpeg obviously, or use OPENELEC. Videos were playing quite OK on Pi, but when I tried with the heavier videos I got messages of “frame dropping” and vlc was hang (the video section) though the sound was working.
There may be the case that your user PI is not added in the video group so you may not have the permissions to play the videos, so simply add it to the video group.
- sudo usermod -aG video pi
which simply means to append the user the Group. Here video is the group and pi is the user. Note as the man page says use -a only with -G option, not to append elsewhere.
Sincere thanks to wrightrocket!!
About Beyondan electronics hobbyst, 8 bit microcontroller(8051/AVR/Arduino) programmer, Linux lover, in love with Embedded Linux systems ... TGL: just push it "BEYOND THE LIMITS"..
Posted on September 29, 2012, in Embedded Linux, Embedded Systems and tagged audio, configuration, days gap, install, mpg123, raspberry pi, root shell, sound modules, sudo, Video, vlc media player. Bookmark the permalink. 2 Comments.