[BATCH] Record Scanner Audio

Not open for further replies.


Aug 10, 2015
Salinas, CA
Hi all!

The problem I was having
I've been having trouble recording dispatch audio at regular intervals for archiving purposes. I wasn't too keen on VOX type recording as Audacity has a really good feature to do that. My issue was I wanted 24/7 recording of audio and to create directories and timestamp the files to easily read. I took information from multiple sources, and decided I would compile it all together for someone else who may want something similar.

Shout outs and thanks
I would like to say thanks to RadioReference and it's helpful members who's posts were invaluable in my research. I would like to point out this thread:

Without it, and AggieCon's posts, I wouldn't even know where to begin.

Required Download
First things first, you need to download ffmpeg, it's available here:

Be sure to download either the Windows x86 version or the Windows x64 version depending on your operating system.

Setting up ffmpeg
Extract the downloaded zip to you root drive (most commonly C:\)

Rename the ffmpeg folder to ffmpeg. The file structure to the ffmpeg binary should be:
Customizing Folder Structure, Timing, and Dated folders
With Windows 7, I had permissions issues so be sure to run as administrator. I keep the batch file (named whatever you want) in the C:\ directory. Furthermore, the permissions issue also caused my recordings to not start due to a missing file, so I added a few lines to the batch file. One last note is that the directories (other than the date) is hardcoded. I provide and record the feed for Salinas Police Dispatch and my stored archives are C:\SPDDispatchArchive Now, this can be named and placed wherever you want, just be sure to change the directory accordingly in the pushd command on line 4 as well as the ffmpeg line on line 10. The file name will look like the following (For 04/27/2017 at 2100): spd_04-27-2017_21h00m00s.mp3 You can also change the "spd" prefix to the abbreviation for the department you would like. This script also organizes the files in dated folders. The file structure ultimately looks like:
So that's about it for customization of the file names and folder structure.

As for the duration of the files, you want to pay attention to the "-t 86400" which is saying 24 hours. That is saying it will record for 24 hours. The next is the -segment_times 3600,7200,10800,etc" parameter which is telling it every 3600 seconds to split the file (1 hour) If you want to change this to say, 30 minutes, you would adjust it to start at 1800 and keep adding that to itself until you reach 84600 (1800,3600,5400,7200,etc)

Discovering your device name for ffmpeg command
Ok so now that I've explained a few things and the important parts, there is one more thing we need to get before we make the batch file. For the ffmpeg, it needs to know what device you're using to capture the audio for the recording. To figure this out, you do:
Open CMD prompt in the ffmpeg bin directory (remember that from ealier? C:\ffmpeg\bin)
ffmpeg -list_devices true -f dshow -i dummy
This command will list out the devices that ffmpeg recognizes. In my case, it stated my device name as:
Microphone (Realtek High Defini"
this is used for the audio="" parameter for ffmpeg.

Ok, now we can put everything together, and just simply change anything you want in this batch file to suite your specific needs.

The actual batch script
@echo off
title Stevens Dispatch Scanner Recorder for Vince - Thanks AggieCon (RadioReference)
pushd "C:\SPDDispatchArchive"
echo Creating a Directoy for the Day
mkdir %date:~-4,4%-%date:~-10,2%\%date:~-4,4%-%date:~-10,2%-%date:~7,2%
echo New recording session started...
pushd "C:/ffmpeg/bin"
ffmpeg -f dshow -i audio="Microphone (Realtek High Defini" -t 86400 -acodec libmp3lame -ac 1 -ar 11025 -aq 7 -f segment -segment_times 3600,7200,10800,14400,18000,21600,25200,28800,32400,36000,39600,43200,46800,50400,54000,57600,61200,64800,68400,72000,75600,79200,82800 -strftime 1 "C:\SPDDispatchArchive\%%Y-%%m\2017-%%m-%%d\spd_%%m-%%d-%%Y_%%Hh%%Mm%%Ss.mp3"
goto newday
Open up notepad, copy the above into notepad, go to Save As and choose "All Files" instead of saving it as a text document and name it whateveryouwant.bat and save it.

Notes and Conclusion
You can set this up to run on startup or as a scheduled task. There are several ways to do it, the simplest being to move the batch file to startup folder. For example Windows 7 is here:
C:\Users\[color=red]USERNAME[/color]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
*Nix/Pie Users note*
I'm assuming you guys know what you're doing and the ffmpeg command should help. Shouldn't be to hard to port this over as a BASH script.

Well I hope this helps some people in the future. Also if you have improvements or suggestions please let me know!
Not open for further replies.