Archive for December, 2008

Google Maps: Get Directions & Weather

Monday, December 29th, 2008

Weather.com’s “Weather On Your Route” page is maddening.  One must laboriously enter the location, date (month and day separately), and the two-hour period for which one would like to see the weather in that location.  When planning a trip during the winter months, traveling primarily from south to north, and near one of the Great Lakes, the weather in some locations may be very, very different than at other locations.  Plugging in this information is tiresome, and I’ve found myself on the Weather.com page entering information before a few days ago, when planning other trips.

After a few quick searches, I turned up one or two Google map applications that kind of did what I was looking to do, but none was quite as simple or as broadly conceived as I had in mind (I make no claims of doing anything close to an exhaustive search).  I wanted to easily enter the beginning point and end point of a trip and I wanted to easily see the weather at various points along the route.  I decided that I would simply create one for myself, which I am sharing with whomever now.  Moreover, I’ve wanted to do something with the Google Maps API anyways for quite some time and this provided a fine excuse.

The little Google Maps application can be found here:

http://www.digitalobjects.org/sandbox/weather-directions/

In any event, the NOAA’s National Weather Service has my gratitude for making its data and forecasting freely available via XML.  The XML is transformed, twice, with XSL stylesheets, once to collate the information in the NOAA XML feed and the second time to sort the information for orderly display in the Google Map application.  I look forward to when XSLT version 2.0 is available as new functions will eliminate the need to parse the data twice.

Batch Audio File Conversion

Friday, December 19th, 2008

I had to make some audio available via the world wide web. But, it had to be protected, in so far as that is possible through basic HTTP streaming. I figured I would place the audio in Flash Video format (FLV), to which I then appended a bogus file extension ending, to complicate the life of anyone who went diving into his or her browser’s cache for the downloaded media. So, I converted the WAV and MP3 files to FLV files (Flash Video Format files).

Again, I used batch scripting, but I also used two additional programs: FFMPEG and FLVMDI. The first, FFMPEG, is a command line audio/video conversion program. It’s used to convert the WAV or MP3 file to FLV. The second, FLVMDI, grabs some information about the FLV file, such as creation time and duration, etc., and, in this case, saves the information to an XML file. Here is an example. I needed the metadata for two reasons: preservation purposes (so I could see something about the file when it was stored in the system) and the duration element was necessary when playing the audio.

Two batch scripts: wavs2flvs and mp3s2flvs.

wavs2flvs

@echo off

echo.
echo This file converts WAV files to FLV files.
echo FFMPEG and FLVMDI are required programs.
echo This file presumes there are files in the wavs_todo subdirectory. 
echo The output (sub)directory, /flvs, should already exist.
echo The converted WAV file will be moved to /wavs, which also should exist.
echo Sample Rate set at 192.
echo Bitrate set at 192.
echo.

SET CURRDIR=%CD%
SET FFMPEG=C:/av_conversion/ffmpeg/ffmpeg
SET FLVMDI=C:/av_conversion/flvmdi/flvmdi

IF EXIST wavs_todo GOTO FLVSOUT
        echo wavs_todo subdirectory does not exist.  Exiting.
        GOTO END

:FLVSOUT
IF EXIST flvs GOTO WAVSOUT
        echo flvs output subdirectory does not exist.  Exiting.
        GOTO END

:WAVSOUT
IF EXIST wavs GOTO CONVERT
        echo wavs output subdirectory does not exist.  Exiting.
        GOTO END

:CONVERT
        cd wavs_todo
        dir *.wav /b > output.txt
        for /f "delims=" %%i in (output.txt) do "%FFMPEG%" -i "%%i" -ab 192 -ar 44100 -f flv "%CURRDIR%/flvs/%%~ni.flv"
        for /f "delims=" %%i in (output.txt) do "%FLVMDI%" "%CURRDIR%/flvs/%%~ni.flv" /x
        for /f "delims=" %%i in (output.txt) do copy "%%i" "%CURRDIR%/wavs/%%i"
        del *.wav
        del output.txt
    echo.
    echo Files converted.
    cd %CURRDIR%
    GOTO END
       
:END
echo.

mp3s2flvs

@echo off

echo.
echo This file converts MP3 files to FLV files.
echo FFMPEG and FLVMDI are required programs.
echo This file presumes there are files in the mp3s_todo subdirectory. 
echo The output (sub)directory, /flvs, should already exist.
echo The converted MP3 file will be moved to /mp3s, which also should exist.
echo Sample Rate set at 192.
echo Bitrate set at 192.
echo.

SET CURRDIR=%CD%
SET FFMPEG=C:/av_conversion/ffmpeg/ffmpeg
SET FLVMDI=C:/av_conversion/flvmdi/flvmdi

IF EXIST mp3s_todo GOTO FLVSOUT
        echo mp3s_todo subdirectory does not exist.  Exiting.
        GOTO END

:FLVSOUT
IF EXIST flvs GOTO MP3SOUT
        echo flvs output subdirectory does not exist.  Exiting.
        GOTO END

:MP3SOUT
IF EXIST mp3s GOTO CONVERT
        echo mp3s output subdirectory does not exist.  Exiting.
        GOTO END

:CONVERT
        cd mp3s_todo
        dir *.mp3 /b > output.txt
        for /f "delims=" %%i in (output.txt) do "%FFMPEG%" -i "%%i" -ab 192 -ar 44100 -f flv "%CURRDIR%/flvs/%%~ni.flv"
        for /f "delims=" %%i in (output.txt) do "%FLVMDI%" "%CURRDIR%/flvs/%%~ni.flv" /x
        for /f "delims=" %%i in (output.txt) do copy "%%i" "%CURRDIR%/mp3s/%%i"
        del *.mp3
        del output.txt
    echo.
    echo Files converted.
    cd %CURRDIR%
    GOTO END
       
:END
echo.

Download the scripts:
Audio Conversion Scripts

Entries (RSS)