Posts Tagged mp3
I was using gst-launch to create and handle an audio stream, but when I went to run it on a second Ubuntu box I could not figure out why I was getting an error.
Here was a section of my command:
gst-launch-0.10 pulsesrc device=alsa_output.pci-0000_02_02.0.analog-stereo.monitor ! audioconvert ! audio/x-raw-int,channels=2,rate=32000 ! lamemp3enc ! ...
I got this error:
WARNING: erroneous pipeline: no element "lamemp3enc"
Looking through Synaptic, I could not find out how to get this
lamemp3enc installed, try as I might. I checked the GStreamer Reference, which says it’s part of the “ugly” plugins set. But after installing gstreamer0.10-plugins-ugly I was getting the same error. It turns out I needed to enable the multiverse repository and install gstreamer0.10-plugins-ugly-multiverse. Install via Synaptic or use the following command:
sudo apt-get install gstreamer0.10-plugins-ugly-multiverse
Hopefully this helps anyone trying to figure out the same issue.
If you’re converting a single file, http://media.io/ is a great online tool. However, for batch conversion, you’ll want to look at one or more of the following tools:
dbPowerAmp is a great conversion utility http://www.dbpoweramp.com/dmc.htm
While dbPowerAmp says Linux is supported through Wine, I’ve found that soundconverter works wonderfully. To install it:
sudo apt-get install soundconverter
Next, just run it. You can select your input files and directories in the GUI. By default, soundconverter produces .ogg output. If you want mp3, simply select it in Edit > Preferences
By default, K3b does not support MP3 file sources for audio CD burning. You can install support for MP3 by running the following command:
sudo apt-get install libk3b6-extracodecs
This is current as of Ubuntu 11.04
The following is (I hope) an adequately-documented procedure to stream desktop audio capture via icecast2.
What you will need:
- Basic audio hardware
- An Internet connection
- Ability to accept inbound connections on a port (default 8000)
- Some basic idea of what you’re doing :)
Setting up the icecast2 server
Icecast2 is a free server for streaming multimedia similar to SHOUTcast. I won’t go in to all of the differences here — you can easily Google them or visit the respective websites and do some light reading. What I will actually explain here is how to get the server actually running.
Install icecast2 from either Synaptic or command line.
sudo apt-get install icecast2
By default, the icecast2 server’s logging configuration is set up in a way that might deeply frustrate the amateur user. This is because it is set up to log to /var/log/icecast2, which is set up with the following permissions:
drwxr-xr-x 2 icecast2 icecast 4096 2011-06-27 23:45 icecast2
That’s 0755 for user icecast2 and group icecast. Fortunately that user and group account are already created for us, but the configuration file isn’t set to change the running process id (it’s commented out) and the entered defaults are for user nobody. No worries. Read on.
Now edit the /etc/icecast2/icecast.xml config file using your favorite text editor. If you don’t mind my recommendation, and you’re doing this on a machine running Gnome or Unity, gedit is excellent. Make sure to edit the file as root.
sudo gedit /etc/icecast2/icecast.xml
Edit the file to your preference.
The next settings change depends on whether you’re running Ubuntu Desktop or Server. Find the section below that applies to you.
Ubuntu Desktop: Make sure to head down to the bottom and make the important change to set the correct user/group combination. Find the
section and uncomment (remove the
--> marks) from around the
to icecast2 and
to icecast, like so:
Now start the icecast2 server
sudo icecast2 -c /etc/icecast2/icecast.xml
You should see messages similar to the following:
Changed groupid to 125. Changed userid to 115.
… and then the program will not produce any more output, but remains running (does not drop back to a prompt). Congratulations, your icecast2 server is running. If it produced an error message, or dropped back to a prompt, investigate the configuration file for any problems, and make sure the port you have icecast2 set to isn’t being used by another process.
To stop the server, hold ctrl and press c (CTRL-c). It does take a few seconds after the keypress to completely halt.
Ubuntu Server: Edit the /etc/default/icecast2 file. The uid and gid should already be set correctly. Verify they are set as follows:
# Name or ID of the user and group the daemon should run under USERID=icecast2 GROUPID=icecast
Next, follow the instructions on the last 3 lines:
# Edit /etc/icecast2/icecast.xml and change at least the passwords. # Change this to true when done to enable the init.d script ENABLE=true
Now start the service
You should get the following output:
Starting icecast2 Detaching from the console icecast2.
Finding your audio device for streaming
I tried using various programs to set up my audio stream, such as the SHOUTcast Transcoder (sc_trans), darkice, and a few others that I don’t even recall — but none worked correctly for my case. The reason? I either couldn’t figure out what audio device to use, or it wouldn’t work with the audio device I gave it.
As it turns out, Linux machines primarily use PulseAudio as a sound system and many of these utilities expect or are designed to work with an ALSA sound system. I tried /dev/dsp and /dev/audio as input devices but neither existed on my system. I tried padsp with darkice configured to use /dev/dsp but that didn’t work either. I found Alexandru Csete’s GStreamer article and a few other posts and figured gst-launch-0.10 would be the answer that I needed. As it turns out, that was completely correct.
With all credit to Alexandru Csete, here are the steps to find the correct PulseAudio device name for your scenario.
Run the following command:
pactl list | grep -A2 'Source #' | grep 'Name: ' | cut -d" " -f2
You should get output similiar to the following:
alsa_output.pci-0000_01_00.1.hdmi-stereo.monitor alsa_output.pci-0000_00_1b.0.analog-stereo.monitor alsa_input.pci-0000_00_1b.0.analog-stereo
These output ‘monitor’ sources feed your devices entire playback stream — effectively ‘what you hear’. The input sources are a microphone or other line-in device. Select the device appropriate for your scenario. If you are trying to capture a webcam microphone or other removable device, generate this list with your device plugged and then unplugged and then compare the lists to find your device.
Once you have your device name, it’s time to…
Set up your audio stream
gst-launch-0.10 pulsesrc device=DEVICE ! audioconvert ! vorbisenc bitrate=BITRATE ! oggmux ! shout2send ip=IP port=PORT password=PASSWORD mount=MOUNT
An explanation of the options:
- DEVICE: Your audio device (from above)
- IP and PORT: The IP address and PORT number of your Icecast2 server
- PASSWORD: The password to your icecast2 server
- MOUNT: The mount point of your stream.
- BITRATE: The bitrate you want your audio to be (see examples below)
In my case the audio device I wanted to use was:
So my line was:
gst-launch-0.10 pulsesrc device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor ! audioconvert ! vorbisenc bitrate=32000 ! oggmux ! shout2send ip=localhost port=8000 password=XXXXXX mount=stream
The above produces an OGG stream. This works pretty well, but some Windows users report issues with OGG streaming. If you want MP3 streaming instead, try this:
gst-launch-0.10 pulsesrc device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor ! audioconvert ! lame bitrate=32 ! shout2send ip=localhost port=8000 password=XXXXXX mount=stream
Note that if you are streaming to a SHOUTcast server (as opposed to an Icecast2 server), change the command as follows:
mount= and replace it with
protocol=2. Make sure you are connecting on the port specified in sc_serv.conf and not the +1 port. Example:
gst-launch-0.10 pulsesrc device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor ! audioconvert ! lame bitrate=32 ! shout2send ip=localhost port=8000 password=XXXXXX protocol=2
Running this produces output similar to the following:
Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Setting pipeline to PLAYING ... New clock: GstAudioSrcClock
If you get some sort of error investigate your shout2cast settings.
Again, CTRL-c stops the streaming.
At this point, you should have a working icecast2 server and a working stream (via gst-launch-0.10). Congratulations!
I’m sure this guide is far from perfect, so please feel free to share any feedback you may have in the comment sections below. Thank you!
Ubuntu Post-Installation Guide v9.10
Note: Unless otherwise specified, packages are installed/uninstalled using
System > Administration > Synaptic Package Manager.
Repositories are updated in
(System > Administration > Synaptic Package Manager > Settings > Repositories)
(System > Administration > Software Sources)
> Third Party Software (for Jaunty) or
> Other Software (karmic).
Java, Flash Player
By default, openjdk-6-jre is the Java VM used on Ubuntu. This is because OpenJRE is actively developed, while Sun’s Java VM is not. Also, by default, Flash is not installed. To install Sun’s Java VM (which can be successfully installed alongside OpenJRE) as well as Flash Player, install: ubuntu-restricted-extras
Medibuntu (DVD, MP3 and WMA support, etc)
Additional codec support (MP3, WMA, etc) is provided by the non-free-codec in the Medibuntu repository. (See for information) Running the following lines in a terminal will install the correct Medibuntu repository as well as the required keyring to authenticate packages:
sudo wget -cs).list --output-document=/etc/apt/sources.list.d/medibuntu.list && sudo apt-get -q update && sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring && sudo apt-get -q update
Following that, install the following packages:
libdvdcss2 (Allows to read encrypted DVDs)
non-free-codecs (Additional codecs)
On supported video chipsets and with the correct video drivers, Compiz can enable a variety of visual effects. If Compiz is supported on your system, it can be enabled via System > Preferences > Appearances > Visual Effects and settings the level to Normal or higher. If compiz is enabled, it is recommended to install compizconfig-settings-manager
Other Useful Programs
The following packages are useful, and installation is encouraged:
–sound and video:
(music management application which also supports a wide range of MP3 players)
While empathy is the new default IM client, pidgin is recommended for facebook users. Empathy, at the present time, does not have the same level of facebook
support that pidgin has). install:
pidgin and pidgin-facebookchat
gnome-format (a tool to easily format removable memory cards)
fglrx-amdcccle – Catalyst Control Center for ATI graphics cards
nvidia-settings – Tool for configuring the NVIDIA graphics driver
nautilus-wallpaper – Adds ‘Set as wallpaper’ to right-click menu
nautilus-image-converter – Adds ‘Rotate’ and ‘Scale’ image commands
to right-click menu
A free Virtual Machine system.
virtualbox-ose is available directly from Synaptic, but does not support USB device pass-through (allows the VM to communicate with USB devices). Sun’s VirtualBox 3.0 does support USB device pass-through easily.
See http://www.virtualbox.org/wiki/Linux_Downloads for instructions on how to add the VirtualBox repository to your system. After adding that repository, you can install the virtualbox-3.0 package.
Be sure to give yourself access to VirtualBox using System > Administration > Users and Groups
and give yourself User Privileges to ‘Use VirtualBox’
Intel microcode update
Systems with Intel CPUs should install the intel-microcode package. This provides an updated microcode to the processor at boot-time which can address processor errors and lock-ups.
Broadcom wireless issues
Systems with broadcom wireless cards which are detected but do not show any wireless networks should install the b43-fwcutter package. This provides an updated firmware for the card which fixes numerous issues. This would have to be installed using a wired network.
Dropbox on Ubuntu
Add the repository line for your Ubuntu distribution and install the nautilus-dropbox package (Reference: http://www.getdropbox.com/downloading)
It is strongly recommended to use software that is distributed in the repositories. If you need to install a program from another source, the .DEB format is the best choice. This installs the program and adds a listing in Synaptic for easily unisntalling the program when you want to.