README
Abstract
This project sprang from a simple idea. Before
2007, the First Unitarian Society (FUS) used an analog sound system http://www.firstunitariansociety.org/technical/sound/old-schematics/sanctuary-PA_v2.gif
where Sunday Assemblies were recorded to cassette tape for historical purposes
and for the benefit of members not present.
The office staff would duplicate tapes upon request for a nominal fee. This involved delays, labor, a filing system,
tape supplies, equipment and overhead. In
addition, special “Music Sundays” were independently recorded (with better
microphones) directly to an audio CD burner.
With a new digital sound system, the possibility of same-day,
high-quality mp3 recordings on the web was irresistible. No longer would we need to wait, nor staff have
to copy tapes, nor aficionados have to duplicate efforts for higher-quality.
Stereo wav files are prepared from multi-channel Cubase recordings
and dropped in a folder. This software provides
an automated process to prepare and upload mp3 files individually or in bulk.
This DOS script, intended for a Windows PC or server, is
all you really need to create mp3 files (using LAME) and transfer (using
Window’s built-in ftp client) to a website like http://www.firstunitariansociety.org/mp3/?C=N;O=D
Any number of wav files can be dropped in the Rip4Web folder for processing. Data are normalized (using normalize.exe) to
the full dynamic range, archived (suitable for burning CDs), and ripped to mp3
using the encoder of your choice (LAME
included, but we’ve also used Blandenc).
A pair of folders lets users choose to create standard (192) or maximum-quality
(320 kbps) mp3 files. The latter includes
"320kbps" in the mp3 filename so you can drop identical wav files in
both folders and get both bit rates in the same web directory without
overwriting. All mp3 files are uploaded
to the site specified by ftpcmd.txt using Window’s built-in ftp client. The script writes a log and cleans up after
itself. You can customize any behavior
by editing the script.
Configuration
Unzip the project and put it <somewhere> on your Windows system. Two files need to be edited. Scripts\rip2web.bat needs to be told where
the working directory (wd) is located. Scripts\ftpcmd.txt
also needs this (lcd) as well as your website’s domain, userID, password, and
target directory. An empty hierarchy of
folders has been provided so this will work anywhere you decide to put <somewhere>. For example, at FUS <somewhere> is \\Fus001\Audio_files so rip2web.bat has
set
wd=\\Fus001\Audio_files
on the first line after the comments. The
ftpcmd.txt template should be self explanatory.
Run the script by double-clicking (a small wav file is
included for testing), but you may want to schedule a periodic job using
Window’s Control Panel>Scheduled Tasks>Add Scheduled Task. We run it daily at 5pm so the office isn’t competing
with large ftp jobs for bandwidth. Only
one copy of the script should be running at any given time. No telling what might happen if two instances
access the same file at the same time!
Troubleshooting
The archive step will fail if there is already a wav file with the same
name. If you need to re-rip a wav, move
(not copy) the file from the WebArchive folder to the Rip4Web folder. Files on the web site will be over-written,
so if you get a bad mp3, just rip it again.
If you’re getting zero byte mp3 files, check your Windows firewall. Our new Win2008 server’s firewall allowed
commands (port 21) but not data (port 20).
If the mp3 files are silent or static, make sure the wav
files are 16 bits. LAME can be told to
use other bit-depths, but 32 bit wav files consume twice the disk space. LAME can also read file headers to find the
bit depth, but wav files do not support headers – they assume 16 bits @ 44.1kHz.
::################################################################################
::##
##
::## rip2web version 20080504 ##
::##
##
::## - provides choice of 2 bit-rate
folders
##
::## - archives wavs AFTER normalization ##
::##
##
::## Copyright Craig A. Smith 2008 ##
::## ##
::## This program is free software: you can
redistribute it and/or modify ##
::## it under the terms of the GNU General
Public License as published by ##
::## the Free Software Foundation, either
version 3 of the License, or ##
::## (at your option) any later version. ##
::##
##
::## This program is distributed in the hope
that it will be useful, ##
::## but WITHOUT ANY WARRANTY; without even the
implied warranty of ##
::## MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the ##
::## GNU General Public License for more details. ##
::##
##
::## You should have received a copy of the GNU
General Public License ##
::## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
::##
##
::################################################################################
::## This script normalizes wav files, then
::## archives them (suitable for burning
CDs).
::## A pair of folders lets users select 192 or
320 kbps.
::## The latter will include "320kbps"
in the mp3 filename, so
::## you can drop identical wav files in both
folders, and
::## both bit rates will appear on web.
::## All mp3 files are uploaded to the web site
specified by ftpcmd.txt
::## You also need to configure a working
directory (wd) variable below.
::## The script writes a log and cleans up.
::## Playlists
(m3u files) are regenerated nightly by bash scripts
::##
(generate-playlists.sh calls buildm3u.sh) run on the webserver.
::## That mean
you can rename mp3 files on the website,
::## and the
playlists will be fixed the next day.
::## REVISION
HISTORY
::## candiate1
::##
Normlaizes, prepared 128kbps mp3 with bladeenc and uploaded to web site.
::## candiate2
::## Replaced
bladeenc with LAME –q 0 (thanks Danny) for better sound quality.
::## prepares
high, medium, and low quality mp3s, adds ID3 tags
::## (although
the album cover artwork doesn’t work.
::## Variable
names generalized so there’s less ink – this makes the code easy to maintain
::## and easy to relocate in a filesystem – just
configure a single directory
::## at the beginning of the script, and the names
of the 4 folders relative
::## to each other is all that’s hard-coded.
::## Full command line switch reference
::## http://lame.cvs.sourceforge.net/*checkout*/lame/lame/doc/html/index.htm
::## As
delivered, it populuates 3 urls
::##
http://www.firstunitariansociety.org/mp3/096kbps/
::##
http://www.firstunitariansociety.org/mp3/192kbps/
::##
http://www.firstunitariansociety.org/mp3/320kbps/
::## but you
can cusotmize this with the ftpcmd.txt files.
::## candiate2B
::## Single 192
bit-rate files uploaded to
::## http://www.firstunitariansociety.org/mp3/
::## Removed
".wav" from mp3 file names (thanks Mark) with
::##
http://www.bulkrenameutility.co.uk/Main_Intro.php
::## (id3 title
still has full path however).
::## candiate3
::## Provided 2
folders to encode at 192 or 320 kbps (Music Sundays).
::## Removed
bulk-rename - it works, but doesn't return control.
::## I'll
remove the ".wav" as part of the bash playlist job on the webserver.
::## Added license
grant.
::## TODO LIST
::## remove
path from --tt tag
::######## Configure working directories ########
set wd=\\Fus001\Audio_files
set
source192=%wd%\Rip4Web
set
source320=%wd%\Rip4Web320
set
arch=%wd%\WavArchive
set
scripts=%wd%\Scripts
set
ftpdir=%wd%\ftp2web
set
lame=%scripts%\lame\lame.exe
::######## Name the log file ########
set
logfile=%wd%\RipLog.txt
echo
-------------------------- >> %logfile%
echo
%date% %time% Script Started >> %logfile%
::######## Normalize wavs in place ########
::## from
https://neon1.net/prog/normalizer.html
"%scripts%\normalize.exe" "%source192%\*.wav"
"%scripts%\normalize.exe" "%source320%\*.wav"
echo
%date% %time% Normalization complete >>
%logfile%
::## uncomment
next line for debugging
::pause
::######## Configure Archive folder ########
copy
"%source192%\*.wav" %arch%
copy
"%source320%\*.wav" %arch%
echo %date% %time%
Wavs Archived >> %logfile%
::######## Rip mp3s with encoder of your choice ########
::#### lame 4x faster than bladeenc, sounds
better ####
::## but does
not support *.wav syntax for multiple files
::## -b bitrate
-q 0 takes more time, sounds better, files no larger
::## -m mode
[-a downmix for mono encoding]
::## --tt
title --ta artist --tl album
--ty year --tc comment
::################
::################
Need to REMOVE FULL PATH from %%w
-cas+mg ################
::################
FOR %%w IN
("%source192%\*.wav") DO "%lame%" -b 192
-q 0 ^
--tt "%%w" --ta "First
Unitarian Society" --tl
"%date%" --tc "copyright
2008 FUS" ^
"%%w" "%%w.mp3"
FOR %%w IN
("%source320%\*.wav") DO "%lame%" -b 320
-q 0 ^
--tt "%%w" --ta "First
Unitarian Society" --tl
"%date%" --tc "copyright
2008 FUS" ^
"%%w" "%%w.320kbps.mp3"
::## the
320kbps in filename prevents overwriting 192 file with same name
echo
%date% %time% Finished ripping >>
%logfile%
::## move mp3
files to ftp folder
echo
%date% %time% Moving mp3 files to ftp upload dir >>
%logfile%
move
%source192%\*.mp3 %ftpdir% >> %logfile% 2>&1
move
%source320%\*.mp3 %ftpdir% >> %logfile% 2>&1
::#### Remove ".wav" from mp3
filesnames ####
::#### from
http://www.bulkrenameutility.co.uk/Main_Intro.php
::## this
works, but does not return control.
::## I'll
remove the ".wav" as part of the playlist bash job.
::echo
%date% %time% Trying to remove wav from mp3 filenames >>
%logfile%
::%scripts%\renamewav.bat
:echo
%date% %time% removed wav from mp3 filesnames >> %logfile%
::#### ftp will overwrite existing files ####
ftp -i
-s:%scripts%\ftpcmd.txt
::## -i turns
off interactive prompting, reads commands from file
echo
%date% %time% FTP complete - files uploaded >> %logfile%
dir %ftpdir%
>> %logfile% 2>&1
::######## Clean up
########
echo
%date% %time% Clean-up complete - We are all done >>
%logfile%
::####################################################
Linux BASH and PERL scripts, Apache includes and access files
DAILY.sh – schedules various daily jobs
generate-playlists.sh – puts build
and break together, cleans and renames
buildm3p.sh – found on the web, writes
hierarchy of m3u files.
break.pl – breaks single playlist
into individuals
HEADER.inc, README.inc, .htaccess –
purely website appearance, modify as needed.
These files are intended for a Linux/Apache web server to optionally build m3u
“playlists” (using buildmp3) for the mp3 files.
Playlists are small text files that link to the mp3 files and provide
random access to any point of a recording.
Depending on your software, you can drag the playhead and listen with
little or no delay. I do not understand
this entirely, and would appreciate an explanation how this provides “instant
playback” from anywhere in a recording (even the end) without waiting for the
entire file to download. Can iTunes
negotiate with an Apache web server to say, in essence, “send me that mp3, but
not from the beginning - I only want data starting from some point latter in
the file.” What Apache module(s) are
required to make this work?
For example, try playing these with iTunes
http://www.firstunitariansociety.org/m3u/?C=N;O=D
The playlist script is run every night to regenerate all playlists. This allows us to move, rename, or delete mp3
files, and the playlists will update accordingly. The script also cleans up the mp3 file names because
I couldn’t figure out how to programmatically rename filename.wav.mp3 to
filename.mp3 in DOS.
I would like to thank the FUS Sound Committee for
equipment and purpose, Bob Aderhold for testing, Mark Gibbons for access to the
office network and servers, Dave Leussler for
recommending the LAME codec, Kendyl Gibbons, interns, and other speakers for
providing motivating content on a weekly basis.