Saving streaming wmv files with Linux - Adventures in Switching to Linux

Sunday, December 14, 2008

Saving streaming wmv files with Linux

This past week my sister-in-law was on the radio in NYC and my father-in-law wanted me to try and record it for him. Since I live in North Carolina, obviously the only way to do that would be to stream it over the web. I figured finding and listening to the stream would be the easy part. I listen to streaming radio ALL the time (thanks WUNC!).

Before getting into all of this, you are likely going to need to install some applications. Everything I used was available through the Ubuntu repositories though I do have Medibuntu enabled in addition to all the other easily enable able ones (main, universe, restricted and multiverse). This was also all done using 8.10 Intrepid Ibex. I also know I have several of the restricted packages installed which I am pretty sure is the only reason Windows Media files work. Now for the details.

The hard part would be to actually save the stream. Here is a step by step of what I did:

  • Obviously the first step was to find a stream of the station. She was playing on WQXR - 96.3 FM and I found their Windows Media stream on PenguinRadio.
  • I found that VideoLAN - VLC media player would be my best bet. It also works in Windows too. I didn't try this on Windows but I bet it would work the same with VLC.
  • I had the hardest time trying the many command line options for vlc. I really wanted to download the file and transcode it to wav or directly to MP3 but I just couldn't get that to work. Instead I just saved it directly as WMV and decided to worry about the rest later. I had some trouble with all the many GUI options too so I went with the safer command line route. I used the command line:
    vlc -vvv "http://htc-01.media.globix.net/COMP005996MOD1/meta/wqxr_live_high.asx" --sout '#duplicate{dst=display,dst=std{access=file,mux=asf,dst=/home/forrest/download.wmv}}'
  • Here is the easy to replace version: vlc -vvv "MY_STREAM" --sout '#duplicate{dst=display,dst=std{access=file,mux=asf,dst=MY_DOWNLOAD_FILE}}'

After all that I had a 34.1MB wmv file with just under 27 minutes recorded. At this point I converted it to a wav using mplayer like so: mplayer download.wmv -ao pcm:file=download.wav

Since I wanted to play it safe and be sure not too miss anything I needed recording, I started to recording early and kept it going past time. At first I wanted to use Audacity to trim the file but I had a problem getting that to work so I used a program called sox. To truncate the wav with sox you just specify the trim option, the start time and how long to run (NOT the end time). In my case it was: sox download.wav download-trim.wav trim 14:50 9:39

Next I converted the wav to MP3 so I could make it easy to get to online before burning it to a CD. I was sick of command line options at this point so I used SoundConverter instead of Lame (though it likely uses lame as a back end anyway) to save me the trouble.

8 comments:

Chris said...

Thanks for the vlc command line, works great for video streams too.

JimBova said...

Thank you. As Chris said, it works perfectly for video streams.

Praveen Sarma (www.teluguwebmedia.in) said...

https://plus.google.com/111113261980146074416/posts/HhTtLcz1r8B I installed WMV plugins through ubuntu software center.

Art Phong said...

The capture worked great. Well done with the options.

But I got a downward pitch shift after mplayer converted it to WAV !?

Any ideas?

GMM said...

Hmm, for whatever reason, VLC builds up the file (I see it growing), but then destroys it at the end, once the stream ends, and it leaves ~200k file with no video content.

Maybe this message:
[0x1662d88] main stream output debug: destroying useless sout

Any idea how I can get vlc to keep the saved file around?

Art Phong said...

When I use ffmpeg to convert wmv to wav, it works perfectly. Great.

This was asx streaming audio, no video, so I can't comment on GMM above.

aven peter said...
This comment has been removed by the author.
aven peter said...

I would just like to say thanks, for your instructions worked first time.
wmv file to mov mac