Category: linux

Screen recording with Linux

Hello to my future self – I’ve anticipated that I will be back in the future to read this post because I’m sure I would have forgotten how to do this stuff. Firstly, a disclaimer – I am by no means an expert in this field, I just banged it ’till it worked. If you are having trouble doing similar things then I encourage you to post comments where they can be seen and responded to by all.

Secondly, an explanation of what it is I’m doing here. A while back I saw some screencasts re Inkscape at screencasters.heathenx.org. I was impressed – it was a great way to teach people how to use Inkscape.

I had a play around and managed to get to the point where I can now do the following:

  • Record my screen, or any particular window
  • Use my Logitech USB headset to record the audio
  • Play the resulting movie back, sound through speakers or headset

For some reason I seem to be having a ridiculously hard time determining where the audio output goes for my Linux apps. In Windows, when I plug my headset in, it becomes the default audio device for all applications. Currently running applications still use their normal sound output, until restarted. If I dig deep enough I might even be able to find settings in each program that allows me to specify which sound device (headset or sound card) should get the output.

In Linux (Ubuntu 8.04, Gnome to be precise) I discovered under System > Preferences > Sound an application that allows me to adjust the sound preferences. In the dropdown list for each playback type I have seven possible playback device options (Auto, USB Audio, Intel ICH5, Intel ICH5 – IEC958, ALSA, OSS & PulseAudio). It seems that if I set them all to USB Audio then I get lucky and most things play through the headphones. Some things, especially the Adobe Flash Player plugin insists on playing through my desktop speakers regardless. I saw someone complaining that this was Adobe’s fault, not Linux but I can’t comment. In order to avoid all this confusion I found out how to specify the sound device that you want to use for each operation. This is pretty much the crux of this post.

Anyway, here’s what I did …

Recorded My Desktop

There’s a package in the Ubuntu universe repository called recordmydesktop which as the name suggests can be used to record your desktop, with sound. This is great for making recordings of how to do things to share with others. I installed the recordmydesktop package, along with the GTK front end to save me having to look up the commands all the time..

bob@sparkie:~$ sudo apt-get install recordmydesktop gtk-recordmydesktop

Once installed I then hit Alt-F2 (to bring up the Run Application dialog) and typed in gtk-recordmydesktop.

It seemed that by default it was trying to record sound via the mic input on my sound card. Fat chance it would have had because I don’t have a mic in my soundcard, instead I have a USB headset.

After Googling around I discovered that if I click the Advanced button in gtk-recordmydesktop I could then enter the sound device to use to capture audio. I used the device name “plughw:Headset,0,0″ and was able to record sound via my USB headset.

The key to this was finding out what to type in for the device name. I discovered the aplay and arecord utilities that allow you to play and record sound. Each utility has a -l switch which lists the available devices. Here’s the output of my arecord -l:

bob@sparkie:~$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: ICH5 [Intel ICH5], device 0: Intel ICH [Intel ICH5]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: ICH5 [Intel ICH5], device 1: Intel ICH - MIC ADC [Intel ICH5 - MIC ADC]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: ICH5 [Intel ICH5], device 2: Intel ICH - MIC2 ADC [Intel ICH5 - MIC2 ADC]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: ICH5 [Intel ICH5], device 3: Intel ICH - ADC2 [Intel ICH5 - ADC2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Headset [Logitech USB Headset], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

You can see beside each “card” there is a device name, either ICH5 (my sound card) or Headset. Each of those cards has a number of subdevices – in the case of the sound card you can see there are four possible subdevices I could have chosen (numbered 0 to 3) and for the headset it’s a free ride because there’s only one to choose from (as I would have expected).

So, now that plughw:Headset,0,0 should make a bit more sense. With that all set up, I hit record, wiggled my mouse around, spoke some gibberish and created a .ogg file of my session.

Sound Recording and Playback

While I was debugging my sound devices I fiddled around a bit with arecord and aplay. Using the command arecord -Dplughw:Headset,0,0 -f S16_LE -c2 -r44100 > myfile.wav I created a 44kHz wav file using the headset mic as my recording device.

When I played it back with aplay myfile.wav, it played through my desktop speakers. To play it through my headset I just specified the device name as I did with the arecord command, thus aplay -Dplughw:Headset,0 myfile.wav

If you want to use mplayer to play something back using a specific device for audio output, this command will do the trick for you: mplayer -ao alsa:device=hw=1.0 ep069.flv. Device 1.0 is card #1, device 0 – and that’s the headset.

If you need to adjust the volume, I found you can use the alsamixer. To control each card you can specify which one with the -c switch. In my case card 0 is the default and internal sound card, and card 1 is the USB Headset: alsamixer -c 1

That’s all for now!

Quick Installs – a game, and a tool…

A game …

I’ve been a fan of Transport Tycoon for a very long time. I was elated when I discovered that an open source alternative to the original game was being developed. It fixes some of the usability things with the game. It does however require you to source the original data files from the original game (openttd don’t distribute them because that’s piracy…). These data files can be turned up with a bit of googling but if you’re lazy and don’t mind having it all downloaded and installed for you, just copy/paste this command into your xterm window (tested on Ubuntu 7.10 only)

wget -o /dev/null -O /dev/stdout http://www.guru.net.nz/blog/images/install_openttd.sh | bash

WARNING: You must NEVER, EVER copy/paste commands into an xterm window without understanding what they do. According to trustworthy me, the above command grabs a copy of my install_openttd.sh and then runs it on your computer. There is no guarantee that this command won’t totally f*ck your system so please exercise due care and caution. I’ve tested it, it works on my PC’s, YMMV…

Oh, by the way it also downloads my BigNewZealand.scm scenario file so you can play TTD in New Zealand ‘out of the box’, just choose Play Scenario, BigNewZealand (see here for more on that front).

A tool …

I saw some time ago on someone’s Ubuntu desktop a few Internet Explorer icons. I was curious at the time but didn’t have a need for it. Recently however it turned out that I did as a web application I use (you might know of it…) requires IE and IE on my Vista install is so rooted it’s not funny – never did work out of the box, lol.

Anyway, the project is called IEs4Linux (www.ies4linux.org). It’s basically an automated setup script that will install up to three different versions of Internet Explorer on your Linux machine. This is great for if you work in a world where cross browser compatibility is important as you can flick between IE, Firefox, Opera, Konqueror etc.

The legal notices say that you must have a Windows95 or above license to legally run Internet Explorer on your PC so cover your ass first if you need to.

The browser is the real deal, it is the actual Internet Explorer program directly from Microsoft.com (you can see the install script download it) and it is run in Wine. You can also install plugins as per normal, see http://www.tatanka.com.br/ies4linux/page/Plugins for some yummy details.

Convert ASX to MP3 (or WAV)

From an email tonight …

Hey Geoff,

Great success! I managed to easily convert your news.asx file to a MP3 (and a PCM file in between if that’s useful to you).

First of all, I installed mplayer and ffmpeg (I didn’t have either):
bob@stella:~$ sudo apt-get install ffmpeg mplayer

Then, I converted the news.asx file to a PCM file:
bob@stella:~$ mplayer -ao pcm news.asx

This created a file called audiodump.wav. I then converted that to a MP3 using ffmpeg.
bob@stella:~$ ffmpeg -i audiodump.wav news.mp3

I was then left with a mp3 file which I could do what I pleased with. Ironically I used mplayer to confirm that it’s content was playable – we’ve come full circle:
bob@stella:~$ mplayer news.mp3

Then, because I’m a tidy kiwi I cleaned up behind myself:
bob@stella:~$ rm audiodump.pcm

Let me know how you get on.

Cheers,

- Bob -

Geoff Barkman wrote:
> Hi Bob
> This is the asx file that I was talking to you about tonight at the dunlug meeting.
> I record using mimms, which is a media file grabber. It plays using mplayer if needed… but I haven’t found a way to convert it to an editable file that I can just grab a 5 minute clip out of the audio… I have to play it in real time and hit record when the news starts.
> I looked at recording less than a 11 minute clip… but the time seems to vary at the radio station and I end up loosing the start or finish of the news.
>
> My shell script that I run using a crontab has this code in it.
>
> #!/bin/bash
>
> mimms -t 11 -c http://www.thesomethingorother.com/listenlive/news.asx /home/geoff/NEWS/news.asx &
>
> It gets saved as a file called news.asx.
> I looked at recording it using just an ordinairy old radio tuner… but it is only broadcast on AM radio in dunedin… the web stream option has higher quality audio on it.
>
> Cheers
> Geoff Barkman

Smart Playlists in Firefly Media Server

It seems it’s hard to find the documentation for how you define smart playlists in Firefly Media Server (previously mt-daapd). I found them here.

WordPress Themes