Posts Tagged Linux

Broadcasting a multimedia stream using icecast2 and gst-launch in Ubuntu Linux

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 <!-- and --> marks) from around the section. Change to icecast2 and to icecast, like so:

icecast2
icecast

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

/etc/init.d/icecast2 start

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

Example command:

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:

alsa_output.pci-0000_00_1b.0.analog-stereo.monitor

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:

Remove 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!

, , , , , ,

Leave a comment

Guild Wars on PlayOnLinux

Here’s a quick run-down of the steps that I took when setting up Guild Wars on a friends Ubuntu machine under PlayOnLinux.

We chose PlayOnLinux because of the ability to use Wine prefixes, so we could customize the Guild Wars prefix for best play experience and no interfere with other configured Wine software. It also gave the easiest installation experience. We also chose PlayOnLinux as a free alternative to commercial programs like CrossOver Games.

Your experience may vary but this is what worked for us.

First, install PlayOnLinux either from Synaptic or the command line.

sudo apt-get install playonlinux

PlayOnLinux will be found under Applications > Games > PlayOnLinux (Gnome) or can be searched for in Unity.

Next, install Guild Wars

After starting PlayOnLinux, click the Install button, then click Games in the left column, and locate Guild Wars on the right side.  Click Apply. Follow the on-screen dialogs to complete the installation of Guild Wars.

Once Guild Wars is installed, it’s time to tune it for performance. Note that much of the following is subjective, and may not be needed under certain circumstances.

— Tune the Guild Wars wine configuration

Once Guild Wars is installed, locate it’s entry in PlayOnLinux and click it, then click Configure this application. The application configurator will open. Click Forward and choose Configure Wine, then Forward again to launch the Wine configuration utility.

Once the Wine configuration utility is open, click the audio tab. If you get a dialog message stating that the audio driver was auto-detected. That’s fine. Set the DirectSound Hardware Acceleration mode to Emulation. Next choose the Graphics tab and under Direct3D, uncheck Allow Pixel Shader.

— Force Guild Wars to start in windowed mode.

Guild Wars will inititally start in full-screen mode. If this causes the client to crash or causes strange graphics issues, you may force it to start in windowed mode using the following terminal command:

WINEPREFIX=~/.PlayOnLinux/wineprefix/GuildWars/ WINEDEBUG=-all wine "C:GWGw.exe" -windowed

This will start Guild Wars in a window.

— Further registry tweaks

Locate the Guild Wars entry in PlayOnLinux and click it, then click Configure this application. The application configurator will open. Click Forward and choose Registry Editor, then Forward again to launch the Wine configuration utility.

Navigate the registry to

HKEY_CURRENT_USERSoftwareWineDirect3D

(If the Direct3D key does not exist, right-click on Wine and choose New > Key and name it Direct3D)

Right-click and choose New > String value. Call it UseGLSL. Double-click on UseGLSL and set Value data to “disabled” without quotes.

See also:

, , , ,

Leave a comment

How to create an ISO in Brasero

This will explain how to create an ISO image from a CD/DVD using Brasero in Linux.

First, insert the disc from which you want to make an ISO image. Wait until, and make sure, an icon for the disc appears on your desktop, indicating the disc has been read and mounted.

Next, open Brasero and select the Disc Copy function.

On the Copy CD/DVD dialog, change Select a disc to write to to ISO by clicking on the drop-down itself (not the properties button) and choosing Image file.

Click the Properties button and choose a name and location for the output ISO image and then click Close.

Verify your settings and then click Start copy.

Brasero will start creating your disc image, which will be quite large — up to the full capacity of your media (4.7GB for single-layer DVDs, 8.5GB for dual-layer).

,

Leave a comment

Intermittent wireless connection and disconnects with DD-WRT and Windows 7

If you’re using DD-WRT on your router you may find that certain wireless configurations cause the wireless clients to either be unable to connect or drop connection. This seems to be the most noticeable on Windows 7 systems, but likely happens on other systems as well. Note that I did not observe this at all on a Linux-based system and I’m completely unable to explain why. Perhaps a difference in the wireless stacks between Windows and Linux highlights this issue.

Issues related to this include not being able to connect to the wireless AP, instead receiving a message such as “The access point did not allow the connection” or something similar (Apologies, I don’t have the exact error message.), and losing wireless connection to the network or AP, even though it is still shown in the list of wireless networks.

This appears to be related to the wireless security settings, specifically the settings for security mode and WPA algorithm. See the following screenshot:

ddwrt_wpa_mixed

Having the security mode set to WPA2 Personal Mixed and the algorithm set to TKIP+AES appears to cause the problem.

According to the DD-WRT help:

WPA2 Mixed
This mode allows for mixing WPA2 and WPA clients. If only some of your clients support WPA2 mode, then you should choose WPA2 Mixed. For maximum interoperability, you should choose WPA2 Mixed/TKIP+AES.

So, according to this, it should work — but it doesn’t seem to work quite as advertised. Instead, this is the recommended setup as long as all your wireless clients support WPA2:

ddwrt_wpa

Security mode set to WPA2 Personal and algorithm set to AES only appeared to completely solve the problem.

For the curious, this is DD-WRT v24-sp2 (08/12/10) mega (SVN revision 14929), the current recommended build.

, ,

Leave a comment

Ubuntu not booting with nVidia video on i3-i5-i7 Intel CPUs

Systems with i3/i5/i7 chipsets and nVidia video may experience Ubuntu not booting, and instead getting a blank screen with a flashing cursor or corrupt video display.

This seems to be an issue with some combination of kernel, video card, and nouveau driver, and appears to stem from the fact that the system technically has two sets of video hardware: that on the Intel CPU and the nVidia GPU.. While the Ubuntu developers work to get this corrected, there is a workaround to get you going.

When your system starts to boot up, hold the shift key to get to the GRUB menu, then press ‘e’ to edit the command line. Go to the kernel line (the line that starts with linux and has quiet splash in it) and press the ‘end’ key to scroll to the end of the line. Add nouveau.modeset=0 to the end of the line, then press F10 to boot.

After booting up, you can install the nVidia proprietary drivers and reboot and graphics will work great for you.

You can also permanently disable the nouveau module by running the following:

echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
sudo update-initramfs -u

You may experience a low-resolution splash or login screen. See my post nVidia proprietary drivers and low-resolution Plymouth splash screen for a solution to this.

See also: Troubleshooting Nouveau Drivers

, , , ,

Leave a comment

Ignoring hidden directories in CrashPlan for Linux

By default, CrashPlan backs up everything in your home folder including all hidden directories (directories starting with a dot (.). This would include some directories your probably don’t want backed up, such as ~/.local/share/Trash (your trash) and a bunch of other hidden directories.

Fortunately CrashPlan’s file exclusion feature includes a way to specify exclusions by regular expression. Simply go to Settings > Backup and next to Filename Exclusions click the configure button.

Check the box for Regular Expression and enter this:

.*/..*

Click the plus sign, then ok, then save again.

That will exclude all the dotted directories from your backups.

Reference: CrashPlan Support – Using Regular Expressions (regex)

Have any filename exclusions that you use on your backups? Feel free to share your rationale in the comments below!

, , ,

Leave a comment

CrashPlan backup to Samba share on Linux

For about a week now I’ve been wrestling with implementing a system where CrashPlan would backup to my network drive. I ran into a really bit problem: When you mount a network location in Gnome using the GUI (gvfs), root can’t access it. Since the CrashPlan engine runs at root, it makes the network location unusable as a backup destination.

After a while of working on different ways to solve this rather large hurdle, I came up with the idea of simply mounting the network location using smbmount (mount.cifs). After some testing and tweaking, I was able to get it successfully working and added an entry to fstab to have it mount at boot time. I chose /mnt/mynas as the mount point.

See Synology DiskStation and Samba mount permissions for my method of getting it mounted with the correct file permissions.

Once it was set to mount at boot-time, I can now open the CrashPlan client and set /mnt/mynas as a destination folder, and now I have both local and off-site backups!

Feel free to share your thoughts and/or feedback in the comments below!

, , , , ,

Leave a comment

Synology DiskStation and Samba mount permissions

So today I was using smbmount to mount a network share from my Synology DiskStation to my Linux PC when I noticed a rather annoying file permissions issue that I couldn’t seem to fix. Why am I using smbmount and not Gnome’s GUI to mount? Because I need root to have access to the file system as well so that CrashPlan can back up to it.

Here’s what happened:

First, I mounted the share (as root):

smbmount //diskstation/mike /mnt/mynas -o credentials=/home/mike/mike.cred,uid=mike,gid=mike

(For more information on the smbmount or the mount.cifs credentials file, see the Ubuntu manpage for mount.cifs)

That worked great, except for when I do this (as root)…

ls -ld /mnt/mynas

… I get the following output:

drwxrwxrwx 17 mike mike 0 2011-05-20 09:25 mynas

I sure didn’t want the directory world-writable. So I tried specifying file_mode and dir_mode as both 0755 using the following (as root):

smbmount //diskstation/mike /mnt/mynas -o credentials=/home/mike/mike.cred,uid=mike,gid=mike,file_mode=0755,dir_mode=0755

Then I checked it:

ls -ld /mnt/mynas

… and got:

drwxrwxrwx 17 mike mike 0 2011-05-20 09:25 mynas

That didn’t do anything at all to help. Why? Because as it turns out the DiskStation is using a Samba server with CIFS extensions and is passing the permissions to smbmount (mount.cifs). The file_mode and dir_mode options are ignored if the remote server is using CIFS extensions.

file_mode=arg

If the server does not support the CIFS Unix extensions this overrides the default file mode.

dir_mode=arg

If the server does not support the CIFS Unix extensions this overrides the default mode for directories.

Source: Ubuntu manpages.

So there’s a couple of options here. First, I could set it to mount somewhere inside /home/mike, which would generally protect it. But I’d really like to know what’s up with the file permissions. So I did a little more Google-fu.

As it turns out, the CIFS extensions on the DiskStation can be disabled, all it takes is to edit a file. Lepoulpe posted on the Synology forums the following edit:

you can disable “unix extensions” in the ds106’s samba server. To achieve this, you need to add the folowing line in the [global] section of /usr/syno/etc/smb.conf :

unix extensions=no

So, I SSH’d into my DiskStation as root (should be the same password as ‘admin’ if you’re having trouble) and used the vi editor to make the edit. Afterwards, I restarted samba on the DiskStation by doing this:

/usr/syno/etc/rc.d/S80samba.sh restart

Then I remounted the Samba share as root…

smbmount //diskstation/mike /mnt/mynas -o credentials=/home/mike/mike.cred,uid=mike,gid=mike,file_mode=0750,dir_mode=0750

… and checked the permissions:

ls -ld /mnt/mynas

… and got the following output:

drwxr-x--- 17 mike mike 0 2011-05-20 09:25 mynas

Exactly right.

So now I have /mnt/mynas mounted to my share on the DiskStation. If I wanted it to mount on boot, I could add something like the following to /etc/fstab:

//diskstation/mike /mnt/mynas smbfs auto,credentials=/home/mike/mike.cred,uid=mike,gid=mike,dir_mode=0750,file_mode=0750,user 0 0

Questions about my method? Have any feedback or alternate methods to share? Please feel free to do so in the comments below. Thank you!

, , , , , , ,

Leave a comment

convmv – Useful linux filename conversion utility

Every now and then I’ll run into an issue with a website’s uploader. They ask me to upload a picture, but then when I click their upload button, none of my pictures appear in the dialog. After troubleshooting for a few, it turns out that they’re limiting file masks to [*.jpg, *.jpeg, *.bmp, *.png] etc. But — because I copied my pictures over from a windows installation, they have all-capital file extensions. Linux uses a case-sensitive file system, so it regards these as different. Renaming a file to a lowercase extension [*.jpg] caused it to show up in the dialog which is what I wanted — but manually renaming thousands of pictures in dozens of directories was out of the question.

I could have written a bash script to do the renaming in a few minutes but I found something better — convmv. This simple utility makes filename conversions / renaming a breeze. By default, it runs in ‘test’ mode so that you can see what will happen before it does the job.

For my case, I needed to rename all the files to lowercase, so I used:

convmv --lower *

That showed me a verbose listing of everything it would do (test mode). However, I wanted to do the entire Pictures folder and everything under it. The new command from my Pictures folder became:

convmv --lower -r *

To get it to actually do the job, I had to specify --notest as well.

convmv --lower -r --notest *

It did it’s work within seconds and everything was lowercase. In my opinion, much easier and better than a bash script.

Convmv has plenty of other options, so next time you need to do filename conversion, check it out.

Questions, comments, feedback? Please share in the comments below. Thank you.

,

Leave a comment

How to tell if your Linux installation is 32-bit or 64-bit

Occasionally you may need to check to see if you’re running 32-bit or 64-bit Linux installation, such as when you’re installing third-party software and they offer 64-bit specific versions.

Fortunately, there’s a very easy way to tell. Simply open a terminal and run the following command:

uname -i

You’ll receive one of the following as output:

i386 indicates 32-bit.

x86_64 indicates 64-bit.

Note that this only states what OS version you’re running, and not necessary the capabilities of the hardware — such can be the case if you installed 32-bit Linux on 64-bit hardware.

If you want to find out if your processor actually supports the 64-bit instruction set (‘long mode’), run the following:

cat /proc/cpuinfo | grep lm

Example output:

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 popcnt lahf_lm arat dts tpr_shadow vnmi flexpriority ept vpid

The ‘lm’ in the flags indicates 64-bit support. Without it, the processor is certainly 32-bit.

 

Leave a comment