Created
July 11, 2020 10:05
-
-
Save darksidelemm/f09c3eb4a0fe837e4fd42347d264d85a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # WIA Broadcast - FreeDV Encoder Cron Job | |
| # | |
| # To be run ~2AM Sunday Morning, to be sure all the required files are in place... | |
| # | |
| # Requirements: | |
| # - freedv_tx and required libs should be in this directory. | |
| # - ffmpeg (available with apt-get, or macports, or homebrew or whatever) | |
| # - wget | |
| # For some reason cron jobs start in the users home directory, so we need to CD first. | |
| #cd /home/darkside/freedv_broadcast/ | |
| # Flag to indicate we're running. | |
| touch i_am_running.txt | |
| # Where we get all our news from! | |
| LOCALNEWS="http://nerc.vk5bbs.ampr.org/WIA_Broadcast/local.mp3" | |
| #WIANEWS=$(date +http://www.wia-files.com/podcast/wianews-%Y-%m-%d.mp3) | |
| WIANEWS="http://www.wia-files.com/podcast/wianews-2016-06-26.mp3" | |
| FREEDVMODE="1600" | |
| OUTFILE=$(date +combinednews%Y-%m-%d.freedv$FREEDVMODE) | |
| echo "Removing existing files..." | |
| #rm *.mp3 | |
| #rm *.wav | |
| rm *.raw | |
| rm local.* | |
| rm national.* | |
| rm combinednews.* | |
| rm combinednews.freedv$FREEDVMODE.wav | |
| echo "Downloading local news: " $LOCALNEWS | |
| wget -O local.mp3 $LOCALNEWS | |
| echo "Downloading WIA National News: " $WIANEWS | |
| wget -O national.mp3 $WIANEWS | |
| echo "Converting Files to RAW" | |
| # At this point we start compiling a temporary file which we will encode with | |
| # FreeDV in a moment. I'm doing this by decoding our source mp3 files to raw | |
| # and appending them to a file. | |
| ffmpeg -i national.mp3 -f s16le -acodec pcm_s16le -ar 8000 -ac 1 - >> temp.raw | |
| ffmpeg -i local.mp3 -f s16le -acodec pcm_s16le -ar 8000 -ac 1 - >> temp.raw | |
| ffmpeg -i wrapup_2.wav -f s16le -acodec pcm_s16le -ar 8000 -ac 1 - >> temp.raw | |
| # The preamble file was created 'by hand', and forms the start of the final output file. | |
| ffmpeg -i preamble.wav -f s16le -acodec pcm_s16le -ar 8000 -ac 1 $OUTFILE.raw | |
| # High pass filter, to hopefully improve audio quality. | |
| sox -r 8000 -s -2 temp.raw -r 8000 -s -2 -t raw temp_hp.raw highpass 300 | |
| echo "Encoding as FreeDV " $FREEDVMODE | |
| echo "Encoding National News" | |
| ./freedv_tx $FREEDVMODE temp_hp.raw - >> $OUTFILE.raw | |
| echo "Producing Final Wave File..." | |
| # Use ffmpeg to add the wav headers to the raw file. | |
| ffmpeg -f s16le -acodec pcm_s16le -ar 8000 -i $OUTFILE.raw $OUTFILE.wav | |
| echo "Uploading..." | |
| # SCP file to a web-visible server. | |
| scp $OUTFILE.wav youruser@yourserver:~/www/temp/freedv/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment