Recently in Open source software Category

I recently decided to embark on a journey of digitizing a box full of audio cassettes. Those who knew me growing up—especially when I was in junior high and earlier—know I was always goofing off with a microphone and a tape recorder. I operated a pirate radio station at AM 1630 for a while too. It’s broadcast radius covered most of the town of Granger, UT, where I lived.

One of the nuggets I found was actually much later than that. In 1995, I had just published (self-published) a book about the World Wide Web titled Fozziliny George Moo’s Guide To The World Wide Web and was asked by a friend to appear on his radio program.

Now, about this friend: His name is Doran Barons. Freaky, right?! My name is Doran Barton! His name is Doran Barons!

He saw a letter I had written to the editors of Wired magazine a few months before (which was subsequently published in Wired) and sent me e-mail to introduce himself. This triggered a series of e-mail exchanged between us which led to him inviting me on his radio program, Digital Village a weekly radio program on KFPK, 90.7FM in Los Angeles, CA.

Digital Village has an online MP3 archive of their radio program going back to 2000 and they’ve hosted some impressive guests on their radio program like Neal Stephenson (one of my favorite authors), Bruce Sterling (another of my favorite authors), Steve Wozniak (who started Apple with Steve Jobs), Bruce Schneier, and Lawrence “Larry” Lessig. It’s cool that I preceded such giants. :-)

After I did the telephone interview with the radio program, Doran sent me a cassette tape of the program and I’ve digitized it (with Doran’s permission). So, if anyone’s interested in taking a peek back in time to 1995 to hear about the World Wide Web in its relative infancy, here it is:

It’s clear I was fresh from doing lots of research for my book. It’s fun listening to me advise one of the show’s callers to contact the “site” he was getting his dialup access through to see if they offered anything like PPP, SLIP, or TIA so he could “extend the Internet to his home computer over his dialup line” or he could use lynx at the shell prompt on the Unix system he was dialing into.

Listen to any kind of syndicated talk radio program and you'll usually hear about some companion website the program has. Usually, there are a handful of free things you can get on a program's website, but many of these sites have a pay-to-play members' area where the really good content is. This includes MP3 downloads of the shows, access to live audio and/or video streams, special behind-the-scenes content, forums, desktop backgrounds, etc.

The MP3 downloads are very convenient for people who don't have the luxury of sitting in front of a radio (or driving a car) for a solid three hours while a radio program is broadcast (with advertisements). It's also a boon for people who find radio advertisements annoying.

The only problem with the MP3 downloads is that theme music and produced portions of the program can not, by law, be included in the MP3 file because otherwise the MP3 would be a copyright violation.

Live streams, on the other hand, are not subject to the above described restriction because they're like a broadcast in nature. They're not a time-shift of the original program. So, if you listen to the live stream or even listen to a pre-recorded program as a stream, music and produced segments may be included.

I listen to the Glenn Beck radio program quite often. I used to download the MP3 files to listen to in the car, but it got annoying everytime Glenn and his producers would put together a segment like "Sportscasters at the 2031 animal-human hybrid baseball games", or "The History Of the Democratic Superdelegates" and I would hear Glenn say, "Listen to this... [pause] Oh man! That was great! Wasn't that great, Stu? Oh yeah! Alright! Dan? Wasn't that just the best? Yeah. Oh yeah."

I decided I needed to figure out how to save a stream.

I knew it was possible. Lots of software applications exist for any operating systems that will convert audio from a live stream into a static WAV file or similar. The open source program mplayer is one such example.

Breaking it down

First of all, I needed to figure out how the stream content made its way to my computer.

After I've logged into the Glenn Beck website as an Insider, I can click a link to listen to a stream of a particular hour of the program (or the whole program) in Windows Media format or RealAudio format. I figured I'd have better luck extracting the audio from the Windows Media format, so I went that route. Instead of just clicking the link and letting my web browser find some program that could handle the content, I saved the content to a file and then looked at the file.

The file it saved was a fairly straightforward XML file that looked something like this:

<ASX VERSION="3.0">
  <TITLE>Glenn Beck</TITLE>
  <AUTHOR>Premiere Radio Networks</AUTHOR>
  <COPYRIGHT>Copyright 2008</COPYRIGHT>

 <ENTRY>

    <TITLE>Glenn Beck 1</TITLE>

    <AUTHOR>Premiere Radio Networks</AUTHOR>

    <COPYRIGHT>Copyright 2008</COPYRIGHT>
 

    <REF HREF="mms://a0011.v67134.c6713.g.vm.akamaistream.net/7/0011/6713/v08060322/glennbeck.download.akamai.com/6713/_!/shows/2008/06/03/GLENNBECKWIN20080603.WMA?auth=blahblahblahblahblah" />

    <REF HREF="http://a0011.v67134.c6713.g.vm.akamaistream.net/7/0011/6713/v08060322/glennbeck.download.akamai.com/6713/_!/shows/2008/06/03/GLENNBECKWIN20080603.WMA?auth=blahblahblahblahblahblah
  </ENTRY>

  <ENTRY>

    <TITLE>Glenn Beck 2</TITLE>

    <AUTHOR>Premiere Radio Networks</AUTHOR>

    <COPYRIGHT>Copyright 2008</COPYRIGHT>

    

    <REF HREF="mms://a0011.v67134.c6713.g.vm.akamaistream.net/7/0011/6713/v08060322/glennbeck.download.akamai.com/6713/_!/shows/2008/06/03/GLENNBECKWIN20080603_CLIP01.WMA?auth=blahblahblahblahblahblah" />

    <REF HREF="http://a0011.v67134.c6713.g.vm.akamaistream.net/7/0011/6713/v08060322/glennbeck.download.akamai.com/6713/_!/shows/2008/06/03/GLENNBECKWIN20080603_CLIP01.WMA?auth=blahblahblahblahandblah" />

  </ENTRY>

...and so on.

This XML defines the MMS URLs for each segment of the show. There are several segments each hour. These individual MMS URLs are what I needed to feed to the application that was going to convert the audio stream to a file. In my case, I decided to use mplayer because it's just so good at everything it does!

The command line for doing the stream-to-file conversion looks like this:

mplayer -vc null -vo null -ao pcm:fast:file=dumpfile.wav \
    'mms://a0011.v67134.c6713.g.vm.akamaistream.net/blahblahblah...'

The real magic in the above command is where I use -ao pcm to tell mplayer to use the PCM file writer audio output driver (instead of sending the audio to my speakers).

This gives me a WAV file which I'll want to convert to an MP3 or Ogg-Vorbis file.

To convert a WAV file generated by the mplayer command above to an MP3 file, I use the open source lame tool:

lame -mf -q2 dumpfile.wav GlennBeck.mp3

Or, convert it to Ogg-Vorbis (the completely open and better-sounding-than-MP3 lossy audio codec):

oggenc -q2 --downmix -o GlennBeck.ogg dumpfile.wav

I've now covered the basic mechanical components of converting an audio stream into an MP3 or Ogg-Vorbis file. Next I automate it all.

Automation

Because I'm a long-time Perl junkie, I investigated how I could use a Perl script to act as the glue between the components and get the whole process of capturing a stream and converting it to MP3 or Ogg-Vorbis.

In the above walk-through, I manually logged into the Glenn Beck website with my web browser. To really completely automate this puppy, I wanted the script to log in for me. It didn't take me very long to figure out the Perl CPAN module WWW::Mechanize was what I needed to use.

WWW::Mechanize does several handy things for the programmer. It loads and parses web pages and can follow links, populate forms, and other basic kinds of interaction. It keeps track of its own cookies and session data too.

To get into the Insider area of the Glenn Beck website, members must enter their username and password on the Insider login page.

Looking at the HTML source for this page, I learned the form was named "aform", the username field was named "iUName", and the password field was named "iPassword".

I now had all the information I needed for WWW::Mechanize to log in:

my $agent = WWW::Mechanize->new(
    cookie_jar  => {},
);
   
my $resp = $agent->get('http://www.glennbeck.com/content/insider');
   
if($resp->is_success) {
    $resp = $agent->submit_form(
        form_name   =>  'aform',
        fields      =>  {   'iUName'    =>  'myusername',
                                'iPassword' =>  'shhhhhhhh!', },
        button      =>  'submit');

Walking through the code above: First, I create the WWW::Mechanize object with an in-memory cookie jar (cookie_jar => {}). Next, I use the object to get() the log-in page. If everything works well so far, I tell the object to find the form named "aform", fill in the username and password fields, and submit the form.

One thing I realized as I was debugging my script was that after I logged in on the Insider page, I was immediately redirected to another page. In order for my script to work, it needed to follow the redirect. This was an easy fix:

my $agent = WWW::Mechanize->new(
    cookie_jar  => {},
    redirect_ok => 1,
);

The page I got redirected to has the links on it for the streaming audio, so I'm exactly where I want to be if I want to capture and convert the latest and greatest Glenn Beck Program audio stream.

WWW::Mechanize can find links within the page with a variety of methods. One of these leverages Perl's excellent support for regular expressions. You can also search for links by the order in which they appear. The link I'm looking for looks like this:

<a href="http://www.premiereinteractive.com/cgi-bin/members.cgi?stream=shows/GLENNBECKWIN20080604&site=glennbeck&type=win_show"><img src="http://media.glennbeck.com/images/common/header_media5off.jpg" name="icon5" width="26" height="34" border="0" id="icon5" onMouseOver="MM_swapImage('icon5','','http://media.glennbeck.com/images/common/header_media5on.jpg',1)" onMouseOut="MM_swapImgRestore()" /></a>

So, my script has the following:

$link = $agent->find_link( url_regex => qr/${datestr}.*win_show$/);
$resp = $agent->get($link);

This assumes I have a scalar variable $datestr that contains a formatted date for the show I want to capture.

Originally, I was going to use one of Perl's several XML-parsing modules to make sense of the XML in the stream link, but in the end all I needed was a regular expression to extract the mms: URLs.

my $xml = $resp->decoded_content;
my (@urls) = $xml =~ m/HREF="(mms:[^"]+)"/msg;

This gives me a list of URLs stored in @urls. Now I just need to feed them to mplayer:

$i = 1;
foreach my $u (@urls) {
    my $seq = sprintf("%02d", $i);
    my @cmd = ( 'mplayer', 
            '-vc', 'null', 
            '-vo', 'null',
            '-ao', "pcm:fast:file=${datestr}-${seq}.wav", 
            $u);
    system(@cmd);
    if ($? == -1) {
        print "failed to execute: $!\n";
    }
    elsif ($? & 127) {
        printf "child died with signal %d, %s coredump\n",
        ($? & 127),  ($? & 128) ? 'with' : 'without';
    }
    else {
        printf "child exited with value %d\n", $? >> 8;
    }

    $i++;
}

This little ditty creates an output file for each of the segment streams. These are named something like 20080604-05.wav.

When the loop is finished, I have several WAV files sitting on the disk. Now I need to somehow sew them all together into one big WAV file so I can convert it to an MP3 or Ogg-Vorbis file. For this, I turn to sox. I decided to have the Perl script generate a shell script to run all the sox and lame commands needed.

open FH, ">/tmp/${datestr}.sh";
foreach my $j (1..($i-1)) {
    my $seq = sprintf("%02d", $j);
    print FH 'sox ', "${datestr}-${seq}.wav", " -t raw - | cat >> /tmp/${datestr}.raw", "\n";
}
print FH 'sox -w -s -c 1 -r 22050 ', "/tmp/${datestr}.raw ${datestr}.wav\n";
print FH "lame -mf -q2 ${datestr}.wav ${datestr}.mp3 ";
print FH "--tt \"Glenn Beck Show - $datestr\" ";
print FH "--ta \"Glenn Beck\" --add-id3v2\n";
close FH;

Then, I run the shell script:

system('sh', "/tmp/${datestr}.sh");

Finally, I do a little cleanup:

unlink "/tmp/${datestr}.sh", "/tmp/${datestr}.raw", map({"${datestr}-$_.wav"} (1..($i-1)));

And, I'm done. There are many other ways I could have gone about doing this, but I found a way that worked and ran with it. I'd love to hear from people who have done something similar and how they did it.

Episode 2 of Solitary World has finally hit the YouTube!

In this episode, I talk about NetworkManager which is software for Linux that makes connecting to networks easier and more intuitive. My buddy Dave Baker and I discuss a ridiculous press release that was released in June about research into teens and the Internet. The results will shock you! Well, not really.

Watch the episode on the Solitary World website or on its very own YouTube page.

Fozzout.

1187022600-sw_ep2-xvid-320x240-1.png
1187022616-sw_ep2-xvid-320x240-2.png
1187022632-sw_ep2-xvid-320x240-3.png
1187022645-sw_ep2-xvid-320x240-4.png

Out of turkey lips!

| No Comments | No TrackBacks

How's that for a record amount of time of not posting anything to my weblog/journal/rantpage?

Thanksgiving

Thanksgiving came and went. Christine and I went to her parents' house this year. Adam and Melissa switched their schedule so they'd be going there this year too. Seemed like almost everyone else was there this year too, so next year it will be crickets.

The Colorado tour

The week before Thanksgiving, I accompanied Sons Of Nothing on a four-date tour across the mountain region of Colorado. Stops included Steamboat Springs, Edwards, and Breckenridge.

We were excited about Edwards and Breckendridge because it was the start of the ski season. While the performances were "on," the audiences were thin -- probably due to lackluster promotion.

The two shows in Steamboat Springs were well-attended. The last show of the tour was at Mahogany Ridge in Steamboat Springs. We had never been there before, so we had no idea what to expect. It was, essentially, a bar/restaurant with a raised, carpeted platform at one end of the dining room. They had a faiirly decent sound system, but no lights. Apparently, they expected us to bring our own lights with us, which we didn't understand. Wal-Mart saved the day and we hung three clip-on lights with colored party bulbs in them -- just to get by.

This tour also marked the return of Derek "Goozbach" Carter to the roadie crew. Derek was, as always, great fun to have along and was a hard worker. When we arrived in Breckenridge, we had some extra time, so he hit the slopes to do some snowboarding. It seemed like he had a lot of fun, except for when he hit a patch of ice and caught himself with his left temple. After that, he just looked like an abused, unappreciated roadie.

During this trip, I finally got around to writing some automation for the visual aspect of the show. Up until this trip, I was typing commands into an SSH session by hand to start and stop each visual presentation on the screen(s). For example:

% vim ~/.xscreensaver
% /usr/libexec/xscreensaver/glslideshow -root -pan 8 -duration 8 &
% killall glslideshow; vid ~/video/FloydShow/evil0_2.mpg

The most automation I'd had prior to this was creating macros for running mplayer and xine (like that vid macro shown above, which runs mplayer fullscreen).

My ultimate goal has always been a system with a database backend that stores cues for each song and a CLI frontend for triggering cues. I figured I could make it extensible enough it could be used for visuals, audio effects, and lighting (via a DMX controller). Because of this grandiose goal, I didn't really make any progress toward it.

On this trip, I got fed up with having to remember all the parameters to the screensavers I was using. So, I whipped up a couple shell and Perl scripts to macro-ize the screen savers so I could sstart them up and stop them with a single command. I also created a shell interface for the system as well. It made things so much easier. The audience at the last show at Mahogany Ridge were privy to the best visuals to ever accompany Sons Of Nothing. It helped there wasn't much light to distract them from the screen. :-)

It is somewhat ironic I also decided I'm removing myself from touring with Sons Of Nothing after this trip to Colorado. It's for a million reasons, it seems, I came to this decision. Some of it has to do with my family missing me when I'm gone. Some of it has to do with my growing tired of being around really drunk people. In the end, I've had a great time doing it and I'm ready to start up a new hobby, probably with my family, to try. Maybe paintball (/me winks at Jayce^). Maybe experimental rocketry. Maybe agility trials with our new dog.

I'm still going to be involved with the band and might still show up to do visuals and effects at a show if they need me, but I plan on concentrating on the band's website and the marketing/promotion side of things. Who knows?! I might continue to record my unique style of spoken word on future SoN recordings. :-D

"RRRRRRRRRRRrrrrrrrip!"

Recently, a close friend of mine wasqdivorced from his wife of ~15 years. Learning of this and helping my friend deal with the thick stew of emotional upheaval he's found himself in has been a difficult experience. Honestly, I really dislike seeing people -- especially people I care about -- go through something like this. I've been through a handful of divorces as a close bystander and I know it takes time, more than anything else, for someone to get through it and get back to being a stable, productive individual.

Rock foo

| No Comments | No TrackBacks

A few things to get out of my system here.

Sons Of Nothing at The Depot -- thoughts

Last Saturday, Sons Of Nothing played at The Depot in Salt Lake City.

SoN at The Depot

First, the venue. This was my first time at The Depot and I have to say I was pretty impressed with the place. It nearly has the charm of the late Zephyr Club and is certainly, hands-down, the nicest venue in Salt Lake City. As for other venues the band has played in, I'd compare it to The Big Easy in Spokane, WA and The Mesa Theater in Grand Junction, CO (although it is larger than the latter).

The sound for the show was engineered by "Todd Almighty" (as Thom called him) and it was awesome. Todd engineered audio for SoN the last couple times we played at The Zephyr before it closed down, so we had confidence in the guy. His professionalism and perfectionism still intact, Todd made the set-up and soundcheck, "a joyful experience," Thom said.

Todd got to do his work with one of of the most technologically advanced mixing consoles I've seen in my life. Very cool.

Lighting was a different story. The venue programmed lots of cool stuff into their Jans Hog lighting console (similar to the one I used at the Arts Festival earlier this year) and then lost all that programming due to powering the unit down without saving the programming to a disk. At least, that's how I understood it.

As a result, the lighting for the show was fairly tame. There were a few times when Davey (the lighting technician) did some extra stuff, but mostly he was trying to keep the stage lit using really boring presets.

The lighting was a bit of a disappointment, but in the end, it worked out to our advantage in another way. We recorded the show on 4 video cameras and snagged an audio recording off Todd's board. The lighting, being pretty uniform and generally brighter than usual, worked out good for the video.

Most of the staff I encountered at The Depot were very friendly and helpful. Most were also digging the music.

The band opened for itself, playing a 45-minute set of original tunes before launching into the 2-hour FloydShow. The original tunes sounded great.

Audience turnout was lower than we had hoped. Between 100 and 150 people showed up. That number appeared smaller given The Depot has a capacity of 1200 people. But, the people who came were receptive and generally seemed to enjoy themselves.

A couple geeks I know from UOSP came and said hi too.

Since the show, I've been editing the video from the four cameras and joining it up with the audio from the board. It may become a "bootleg DVD" from the band. We'll see.

If you're interested in seeing some lower-resolution XViD-compressed samples, let me know.

This next week, we'll be taking the same 45-minute originals set and FloydShow performance to three venues in Colorado. We usually get very good response from our friends in CO so I'm looking forward to it.

Rush Replay - DVD

A couple weeks ago, I saw "Rush Replay" on DVD at our local Target store. The price wasn't too bad, but I thought I might be able to find it online for a few bucks cheaper. Sure enough, I did and a few days later, it arrived in the mail.

Rush Replay

This 3-DVD, 1-CD box set has special meaning to me and probably anyone else who was a fan of the Canadian prog-rock group during the 1980s (I got into the band in 1987 or so). This box set features the first DVD releases of the "Exit Stage Left," "Grace Under Pressure Tour," and "A Show Of Hands" live concerts. I still own "A Show Of Hands" on VHS and probably had second or third generation copies of the other two on VHS at one time as well.

The audio for these DVDs has been restored, remastered, etc. into Dolby and DTS 5.1 mixes as well as stereo. The video looks great- as good as it can, anyway, considering the era and medium from which it originated. The DVDs don't offer much in the area of extra features. The packaging, on the other hand, includes some treasures: replications of the original dead-wood programs from each of the tours these DVDs are comprised of.

Since music from "Grace Under Pressure Tour" was never available on CD, the 3-DVDs are accompanied by a bonus CD containing this audio. Very cool.

Rockbox

A couple weeks ago, I decided to take the plunge and try out Rockbox on my iAudio X5 portable music/video player. Rockbox is an open source firmware you can install on a few different popular portable music players including the iPod, iAudio X5, iRiver H100 and H300, and Archos players.

The X5's official firmware already supports MP3, Ogg Vorbis, and FLAC, so I wasn't interested in Rockbox for support of other audio file formats. It was more just curiousity.

Overall, I was very impressed. The Rockbox firmware gave me a lot more control over the X5. The equalization options were vastly superior to the official firmware. I seriously think all my music sounded better with Rockbox, but I admit I may have been imagining it.

In addition to providing similar functionality for playing music, the Rockbox firmware also includes a bunch of toys including a Bejeweled clone, an Asteroids-type game, and some xscreensaver-type screen toys.

I was really only disappointed with two things: First, the Rockbox doesn't play video yet. The X5 will play XViD-compressed video 160x120 (or smaller), but it's very picky, even inside of these parameters. Even iAudio's JetAudio Windows program can't seem to generate totally-X5-friendly videos as well as transcode in Linux can with some experimentation.

Video is coming, though. In the future, Rockbox will be able to do eveyrthing the X5 firmware can do, video-wise, and more.

The second thing Rockbox is missing is the ability to record from line-in to compressed audio files. It can digitize to WAV files, but that takes up a lot of space. By contrast, the X5 firmware lets you digitize directly to MP3.

I looked around on the Rockbox site for some information about encoding directly to MP3 files and it looks like recording directly to multiple audio formats is planned for version 3.1 of the Rockbox firmware (I grabbed the latest which is v2.5). It will be even better if I can record directly to Ogg Vorbis files or FLAC on occasion.

Need an enclosed cargo trailer

If anyone reading this knows of anyone selling or willing to rent or lend-out a small (5x7, 6x8) enclosed cargo trailer, I'd really like to know.

Monthly Archives

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.23-en

About this Archive

This page is an archive of recent entries in the Open source software category.

Music is the previous category.

Perl programming is the next category.

Find recent content on the main index or look in the archives to find all content.