Converting AU to MP3

Status
Not open for further replies.

AC9BX

Member
Joined
Jun 11, 2011
Messages
333
Location
Lockport, IL
Greetings,
If you're like me you're enjoying the usefulness of the the recordings from the scanner. I like to take the previous day or two, drop them into a media player (I'm using Winamp for this) and listen straight through. But, you will notice there's periods of silence. If you lengthen the delay as I've done, as long as 6 seconds for certain things, this silence is just a waste of time when listening back this way. And/or if you would like to play these files somewhere that does not support the scanner's audio format you'll have to convert them.

So, I created a tiny little Windows batch script that processes the recordings and uses FFMPEG to convert them to MP3. MP3 is useful if you want to play them on an Android device, or from a CD-R in the car, or portable media player, etc., anything that will play MP3 but not AU.

The AU format from the scanner uses μ-law algorithm. Most any computer can play this. But your car stereo for example from a USB flash drive or CD-R will not. If you're long term archiving the MP3s will be a little smaller as well.

How it works:

The script resides in the parent folder, My Documents > WS1095 Digital > Audio or wherever you choose to store the recordings. It searches through the parent and all child folders for AU files. I chose to delete everything 6 seconds or less. It's typically silence or the last blip of someone's conversation anyway. It does this by looking at the file size not the duration, and deletes AU files smaller than 60k. Then it calls FFMPEG and converts the AU to MP3 at 32k which is more than enough for the limited audio bandwidth. It also adds a low pass filter to remove the noises of LTR, CTCSS, and DSC, and anything else below 300Hz. It skips silence longer than 1 second. This means silence, where the recording is still going but the signal has stopped. It will not remove signal background noise where no one is speaking such as a repeater that is still transmitting while waiting for a call back. This means if you set delay longer than 1 second those pauses will be removed, much nicer at playback. ID3v2 tags are added with the folder name as artist and file name as title. It then deletes the AU file.

You will need the free FFMPEG tool. If you're not familiar with this it is among the very best and most powerful video and audio conversion and encoding tools. It does everything. This is all free, no license is required for personal use at all.

You can tweak the script as you see fit, use a different encoding tool, whatever. I just wanted to share. I offer no warranty. The script is attached as a zip.

View attachment convert.zip

You can get FFMPEG here. You need the FFMPEG.exe. It must be in the same folder as the script or it can be placed in Windows > System32 where it will be available everywhere in the system. You need not worry about any of the rest. Most any recent build should work fine as long as it has the filters I am using. If it doesn't you can eliminate them from the script. You could of course change all the filter and encoding parameters as you see fit.

https://ffmpeg.zeranoe.com/builds/
 

SCPD

QRT
Joined
Feb 24, 2001
Messages
0
Location
Virginia
I use Audacity .. to join them for events that I want to retain and if needed remove that extra silence.
 

AggieCon

Member
Premium Subscriber
Joined
Nov 25, 2015
Messages
1,448
Location
Texas
Thanks for sharing. I too have experience with FFMPEG.

I find the AU files to be a nice format, specifically the sample rate utilized. The high pass filter is very smart. I do the same when I playback. However, you might also consider a lowpass filer at 4k; I am not sure the encoder is smart enough to ignore everything above (the AU files have nothing about 4k). Alternatively, let it know the input is 8k sample rate and mono. Mp3 should have a mono/8k setting but I can't recall off the top of my head which layer it is.

I prefer the non-lossy format and wouldn't marginalize any files that might already be difficult to understand; so I'd maintain the original files.

Other than that, I think you made a great tool to solve the compatibility problem, and you didn't go crazy on something like 256kbps.
 

AC9BX

Member
Joined
Jun 11, 2011
Messages
333
Location
Lockport, IL
One could certainly use Audacity or Audition or Sound Forge, etc. to do whatever they like with these files.

I wanted convenience, double click the thing and in just a few seconds the whole thing is done, drag and drop the audio folder into Winamp or whatever and the entire collection is queued, or drop onto a CD-RW, burn in just a minute or two, and hit the door.

FFMPEG has a concatenate filter that could perform combining also but the files need to be named in sequence and care has to be taken to make it work as you expect.

There's noting wrong with AU container. It just isn't widely supported away from the computer or the radio.

There's other encoders one could use. SOX is a similar tool to FFMPEG but for audio only and in fact FFMPEG now incorporates some of what SOX has to offer. The sample rate converter in SOX is dramatically better than FFMPEG native for example.

The Lame library has come a long way from where it started, it sounds great. FFMPEG does a very good job at detecting the source files automatically. It struggles with a few things.

I considered a low pass filter but it isn't really required. The sample rate effectively determines the frequency range. These are 8kHz samples and the Nyquist theory suggests the frequency range is limited to one half of that therefore 4kHz. The encoder won't try to do anything with any sound above that because there just isn't any.

Recordings are 16bit (at least they are with CPU version 2.6). Using μ-law or A-law 16bit at 8kHz gives about 64kbps. My MP3 thing is half that. μ-law and A-law are common, still used a lot today, among telephone systems. They're old, the best way to squeeze down the amount of data before more modern compression schemes were developed, usually 8bit is used because it's enough dynamic range for telephone. The carbon microphone elements in the phone wouldn't generate more dynamics or frequencies than 8 bit 8k μ-law could handle.

FFMPEG won't change the sample rate unless you tell it to. It typically won't change bit depth or number of channels either but there's some instances where it may, but not for this. So I don't have to pass any parameters to the encoder other than target bit rate. AAC for example wants to be stereo by default. An MP3 however unlike PCM will have frequency range limitations if the bit rate is too low, there just aren't enough bits to reproduce the whole thing. 32kbps is useful to about 5kHz which is more than we need. Since this certainly isn't Hi-Fi 32kHz is perceptibly lossless compared to the AU.

Using 8bit poses a problem. While it would be okay for the radio audio although it probably will not play in something like a car CD player or set-top DVD machine.
 

AggieCon

Member
Premium Subscriber
Joined
Nov 25, 2015
Messages
1,448
Location
Texas
I downloaded your batch file but have not yet used it. Are the output mp3s stereo or mono?

If they are stereo, there is a way to map the channels to make it mono. I really suggest using mono.

And, it's nice to read on here from someone who actually knows what they are talking about!
 

SCPD

QRT
Joined
Feb 24, 2001
Messages
0
Location
Virginia
I personally find that 16 kbps is the optimal setting when considering size and quality and definitely mono. You do not need stereo for a scanner.

I will not comment on the .. "it's nice to read on here from someone who actually knows what they are talking about!" Sounds pretty rude to say that on a forum of your peers.
 

fxdscon

¯\_(ツ)_/¯
Premium Subscriber
Joined
Jan 15, 2007
Messages
7,203
I will not comment on the .. "it's nice to read on here from someone who actually knows what they are talking about!" Sounds pretty rude to say that on a forum of your peers.

Agreed 100%.

.
 

AggieCon

Member
Premium Subscriber
Joined
Nov 25, 2015
Messages
1,448
Location
Texas
He had a lot of good technical information. Not merely opinion and experience. That's all I meant. I did not mean to upset, and it was meant as a compliment. I assume many -- if not most -- on this forum do not share the OP's level of knowledge in this regard. I bet they'd admit it too. And that's absolutely fine. The whole point of this is to learn and to progress. If everyone already knew it all, it would be a pointless echo chamber. I've helped a number of folks who were vague on certain topics; there's nothing wrong with not knowing. In fact, it's great that people venture out to ask in what can be quite a hostile environment. I merely meant to compliment the OP for offering a good solution to a problem and for explaining with lots of good information. It was refreshing to read as opposed to hundreds of posts about connection a scanner to a computer.
 

AC9BX

Member
Joined
Jun 11, 2011
Messages
333
Location
Lockport, IL
It's mono of course.

Please, anyone feel free to change any parameter you like.

I chose 32kbps because it's already about half the size of the AU files and won't reduce quality/frequency range at all. Again, not that this is hi fi, it's just sloppy scanner recording. One could certainly go with a lower bit rate.

For myself I've added an additional delete small files function. Say, delay is set at 6 seconds. The AU is 7, one second of hash or a bleep or whatever. It isn't deleted in the first go-round. But after encoding you have an essentially useless 1 second clip. I haven't experimented with it yet to see if any tweaks would be useful.

I also added another layer of high pass and moved up to 330Hz. That filter goes only to 4 poles. I may change it to use a different filter with a more steep curve. It's all for experimenting.
 

AC9BX

Member
Joined
Jun 11, 2011
Messages
333
Location
Lockport, IL
Current version

Added routine to delete small resulting MP3 files, after silence removed and remaining duration is very short. Done in process loop instead of at the end just for convenience and perhaps a speed improvement.

Changed creation of parent folder name for file title tag to correct error of folder name with a period in it. 464.25 for example would be truncated to 464.

Changed filter settings slightly
 
Last edited:

AggieCon

Member
Premium Subscriber
Joined
Nov 25, 2015
Messages
1,448
Location
Texas
Yes.

This would be a good download/thread for all of those Wikis.
 

AC9BX

Member
Joined
Jun 11, 2011
Messages
333
Location
Lockport, IL
update

I've made some minor tweaks. This is essentially the same as before.
  • updated comments
  • made initial file deletions smaller, better for shorter delays, this is easily changed by the user
  • updated conversion
  • tweaked highpass filtering

This is faster, not that it was especially slow. A thing about FFMPEG, certain audio filters require certain sample formats, some want planar, some don't, some work at 16bits, some require 32 or Double (64bit). That's all well and good. FFMPEG automatically inserts the resampler as needed. But if one is using multiple filters ordering them such that fewer resamples have to be made will improve running efficiency. Also, the Sox resampler is notably better than the default. (be sure you have a later build that includes the Sox resampler, or change the commands to not use it) No, this isn't high fidelity, it's just good practice and after several conversions it may add up. (resampling adds noise) I elected to insert the resampler manually instead of letting it do it automatically. You can change it as you see fit. Also, I had previously called the anequalize filter repeatedly. That's not necessary as you can add "channels" and call it only once. This may also run faster. Higher frequencies are reduced a bit but the low end filtering is better.

You can use FFMPEG to convert these to anything you like, M4A, Flac, AU, Wav, OGG, etc.
 

Attachments

  • convert.zip
    1.9 KB · Views: 9
  • filtering.jpg
    filtering.jpg
    32.3 KB · Views: 134
Status
Not open for further replies.
Top