Recording an Internet Radio Stream for Free

This should have been easy, but rarely anything in technology is. I listen to a podcast that is just a recording of what is broadcast on AM radio. The problem is if the producer of that show is on vacation or the station is having technical difficulties, it can take days for the podcast to be uploaded.

The first huddle is figuring out what the streaming URL is. This is well hidden, because the parent company probably wants you to go to their website to listen to the stream. You can do this right from a Chrome browser, open the Internet radio stream, then hit the F12 key, go to the Networking tab and looking for anything with m3u8, playlist or stream in the name:

In the above example (which is just a random radio station I picked), the URL is http://ample.revma.ihrhls.com/zc4245. If you copy and paste that into a browser, it starts playing the radio station.

There’s an easier way of getting this information and that’s from this website: https://www.radio-browser.info/. If you type in the station call letters “WISN” in the search, you get a URL of https://stream.revma.ihrhls.com/zc4245, which is very close to what we found before.

Now comes the fun part of figuring out how to record this stream to an audio file. This can be done by using the task scheduler to start up web browser and open our streaming web site address, such as "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "https://stream.revma.ihrhls.com/zc4245". Just throw that into a batch file to make it easier to run.

Then you can use fmedia with the loopback option to record the audio. First, figure out what device you want to record from by running this command:

fmedia --list-dev

You want a Playback/Loopback device that you usually hear things out of, probably your default audio device.

fmedia --dev-loopback=2 --record -o C:\temp\radio.mp3 --until 30 --rate=48000 --channels=mono --mpeg-quality=64

This records the Internet stream for 30 seconds and then saves a MP3 file with a low bit rate of 64kbps, since this is talk radio. If you wanted 3 hours and 30 minutes use --until 3:30. You’ll need to terminate msedge.exe after 3:30 hours, you can do this with a program called pskill. Download the Sysinternals Suite and then put this into a scheduled task after your show ends: pskill -t msedge.exe

This works, but is a bit clunky. Could we just record the Internet audio stream directly? Yes, there’s several options, starting with a GUI one: StreamWriter. This one works great, you just have to turn off the feature for splitting the stream into individual songs (Uncheck save separated tracks in the options). I just have one warning for this solution: this program only outputs the same steam up to 11 audio files with the same name, then it stops writing. It appends a 1, 2, etc. until it gets to 10 and then it stops creating new audio files. The fix is relatively easy with some Powershell code (you would run this some time after your stream ends and recording stops):

Get-ChildItem D:\_RADIO\*.aac | Rename-Item -newname {$_.LastWriteTime.toString("MM.dd.yyyy") + ".aac"}
Get-ChildItem D:\_RADIO\*.aac | Where CreationTime -lt (Get-Date).AddDays(-2) | Remove-Item -Force

This renames all files ending in .AAC to the date the file was created on, such as 09.03.2022.aac and then removes any files ending in .AAC older than 2 days to keep things tidy. I recommend using a batch file to call the Powershell script, it makes it a lot easier to deal with in the task scheduler. In your batch file, just call it like this

powershell -executionpolicy bypass -file C:\temp\yourscript.ps1

ffmpeg can also record Internet radio streams if you prefer a command line option (accepts HH:mm:ss for time notation, I just did 30 seconds here as an example):

ffmpeg -t 30 -i https://stream.revma.ihrhls.com/zc4245 -acodec copy C:\temp\radio.aac

This stream is originally in AAC format, if you want it transcoded to a 64kbps mono MP3 file do this:

ffmpeg -t 30 -i https://stream.revma.ihrhls.com/zc4245 -b:a 64k -ac 1 -acodec mp3 C:\temp\radio.mp3

VLC supports recording Internet audio streams as well, though the command line is a bit tricky to figure out, but this seems to work (note the stop time is in seconds, so convert the time you want accordingly into the number of seconds):

"C:\Program Files\VideoLAN\VLC\vlc.exe" -I dummy -vvv https://stream.revma.ihrhls.com/zc4245 --sout "#transcode{vcodec=none,acodec=mp3,ab=64,channels=1,samplerate=44100}:file{dst=C:\temp\radio.mp3}" --stop-time 30 vlc://quit

To remove commercials from the audio file, I like using mp3DirectCut. You can mark the beginning of the commercials with the B key and then the end with the N key to mark that section and then hit the DELETE key and poof, that section of the MP3 file is gone. No re-encoding of the file required. When done, do a File>Save as and save it as a new file.

To get the audio file over to your Android phone, I like using SolidExplorer’s FTP server option and then using WinSCP to FTP the file over to a folder on the phone. For listening: I like mABook. The skip ahead and rewind is user defined, I set mine to 1 minute and 5 minute intervals, so if you don’t want to remove commercials and just want to try skipping them in the playback app, you can usually get good results fast forwarding in either small or large chunks (long chunks usually being around the hour break).

  • Soli Deo Gloria