36-Hour Imagery Processing script
Here is the Batch file I use to create my 36-hour animations of GOES 16 (or 18) Imagery.
Link to 36-hour imagery generated with this script
Requirements:
Youtube vlog where I talk about this script.
:: USRADIOGUY GOES 16 36 HOUR ANIMATION 12/12/2022 FULL DISK NOMAP CUSTOMLUT
:: TESTING BLOCK IGNORE IF NOT NEEDED
GOTO TEST
:TEST
:: TIME BLOCK- NOTE THIS TIME BLOCK IS RE USED IN MULTIPLE SCRIPTS, SO I LEAVE IT IN IT'S ENTIRETY, EVEN THOUGH ONLY SOME OF THE RESULTS ARE USED.
:: GET UTC times:
for /f %%a in ('wmic Path Win32_UTCTime get Year^,Month^,Day^,Hour^,Minute^,Second /Format:List ^| findstr "="') do (set %%a)
Set Second=0%Second%
Set Second=%Second:~-2%
Set Minute=0%Minute%
Set Minute=%Minute:~-2%
Set Hour=0%Hour%
Set Hour=%Hour:~-2%
Set Day=0%Day%
Set Day=%Day:~-2%
set /a "Twodaysago=1%Day%-2"
)
set twodaysbefore=%Twodaysago:~-2%
set /a "daybefore=1%Day%-1"
)
set Yesterday=%daybefore:~-2%
Set Month=0%Month%
Set Month=%Month:~-2%
set goestoolsdate=%Year%-%Month%-%Day%
set SanchezTime=%Year%-%Month%-%Day%T%Hour%:%Minute%:%Second%
set UTCTIME=%Hour%%Minute%%Second%
set UTCDATE=%Year%%Month%%Day%
set filetime=%Year%-%Month%-%Day%
set starttime=%Year%-%Month%-%twodaysbefore%
set midday=%Year%-%Month%-%Yesterday%
set curTimestamp=%UTCDATE%%UTCTIME%
:: SHOW TIMES ON SCREEN
echo Current Date and time is %UTCDATE%.%UTCTIME%
echo Goestools Current Date and time is %goestoolsdate%
echo Sanchez Current Date and time is %Year%-%Month%-%Day%T%Hour%:%Minute%:%Second%
echo Current File Date and time is %filetime%
echo Yesterdays File Date and time is %midday%
echo Yesterdays File Date and time is %starttime%
:: COPY BLOCK-36 HOURS OF IMAGERY
:: USES A RECURSIVE FOR LOOP TO SEARCH EACH SPECIFIED FOLDER BY THE DATES CREATED IN THE TIME BLOCK AND MOVES THEM TO THE TEMP FOLDER
for /R "D:\GOES DATA CENTER\goes16\fd\CUSTOMLUT\%starttime%\" %%f in (*.jpg) do copy "%%f" "D:\TEMPPROCESSING\GOES16Web_video\"
for /R "D:\GOES DATA CENTER\goes16\fd\CUSTOMLUT\%midday%\" %%f in (*.jpg) do copy "%%f" "D:\TEMPPROCESSING\GOES16Web_video\"
for /R "D:\GOES DATA CENTER\goes16\fd\CUSTOMLUT\%filetime%\" %%f in (*.jpg) do copy "%%f" "D:\TEMPPROCESSING\GOES16Web_video\"
for /R "F:\Satellite Imagery\goes16\fd\CUSTOMLUT\%filetime%\" %%f in (*.jpg) do copy "%%f" "D:\TEMPPROCESSING\GOES16Web_video\"
:: IMAGE OPTIMIZATION BLOCK AND ADD FILE TIME STAMP TO BOTTOM OF EACH IMAGE
:: REDUCE FULL DISK IMAGE SIZE FROM 5424X5424 TO 1000X1000 AND REDUCE FILESIZE SIGNIFICANTLY
for /r "D:\TEMPPROCESSING\GOES16Web_video\" %%a in (*.jpg) do "C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\magick.exe" mogrify -path "D:\TEMPPROCESSING\GOES16Web_video\AUTORESIZE" -type TrueColor -filter Triangle -define filter:support=2 -thumbnail 1000 -unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -strip -gravity south -stroke none -pointsize 28 -fill orange -font Ailerons -annotate 0 %%t "%%~a"
:: APPLY USRADIOGUY WATERMARK TO EACH IMAGE
magick mogrify -path "D:/TEMPPROCESSING/GOES16Web_video/FDWATERMARKED/" -format jpg -gravity northwest -draw "image over 15,15 0,0 'F:/Satellite Imagery/GOESFULLDISKWHITE250x50.png'" "D:/TEMPPROCESSING/GOES16Web_video/AUTORESIZE/*.jpg"
:: ENABLE DELAYED EXPANSION AND RENUMBER IMAGERY FFMPEG PROCESSING WITHOUT GIF
cd /D D:\TEMPPROCESSING\GOES16Web_video\FDWATERMARKED
@echo off
setlocal enabledelayedexpansion
set "index=000000"
for /f "delims=" %%a in ('dir /a-d /b *.jpg^|findstr /rxc:"......[0-9][0-9][0-9][0-9][0-9][0-9]\.jpg"') do (
set "name=%%~na"
if "!name:~-6!" gtr "!index!" set "index=!name:~-6!"
)
set /a i=1%index%
for /f "delims=" %%a in ('dir /a-d /b *.jpg^|findstr /rxvc:"......[0-9][0-9][0-9][0-9][0-9][0-9]\.jpg"') do (
set /a i+=1
set "name=%%~na"
ren "%%~a" "!name:~,6!!i:~-6!%%~xa"
)
move /Y D:\TEMPPROCESSING\GOES16Web_video\FDWATERMARKED\*.jpg D:\TEMPPROCESSING\GOES16Web_video\TEMPVIDEO
:: CREATE INTERPOLATED MP4 RENUMBERED IMAGERY
cd /D D:\TEMPPROCESSING\GOES16Web_video\TEMPVIDEO\
ffmpeg -y -framerate 4 -i "GOES16%%06d.jpg" -filter "minterpolate='mi_mode=blend:me_mode=bidir:fps=25:mc_mode=obmc:me=ds:vsbmc=1'" -c:v libx264 -pix_fmt yuv420p "D:\TEMPPROCESSING\GOES16Web_video\FINAL\GOES36Hours.mp4"
:: DELETE ALL TEMPORARY FILES
del "D:\TEMPPROCESSING\GOES16Web_video\*.jpg" /s /f /q
del "D:\TEMPPROCESSING\GOES16Web_video\AUTORESIZE\*.jpg" /s /f /q
del "D:\TEMPPROCESSING\GOES16Web_video\FDWATERMARKED\*.jpg" /s /f /q
del "D:\TEMPPROCESSING\GOES16Web_video\TEMPVIDEO\*.jpg" /s /f /q
:: Copy a file to location for uplaoding to web "G:\Satellite Related\GOES STUFF\GOES36hours\"
for /R "D:\TEMPPROCESSING\GOES16Web_video\FINAL\" %%f in (*.mp4) do copy "%%f" "G:\Satellite Related\GOES STUFF\GOES36hours\"
:: Copy a file to Vitality GOES "C:\xampp22\htdocs\videos\"
for /R "D:\TEMPPROCESSING\GOES16Web_video\FINAL\" %%f in (*.mp4) do copy "%%f" "C:\xampp22\htdocs\videos\"
::Upload video to server. (HANDLED BY TASK SCHEDULER)
rem "C:\Program Files (x86)\WinSCP\WinSCP.exe""/log=C:\Users\crein\Documents\WinSCPusradioguyG16upload.log" /loglevel=1 /ini=nul /command "open ftp://USERNAME@YOURSITE.com:PASSWORD@YOURSITE.com" "put -latest ""D:\TEMPPROCESSING\GOES16Web_video\FINAL\GOES36Hours.mp4"" /GOES16DATA/" "mv /GOES16DATA/GOES36Hours.mp4 /GOES16DATA/GOES1636Hoursnow.mp4" "exit"
rem del "D:\TEMPPROCESSING\GOES16Web_video\FINAL\*.mp4" /s /f /q
Here are some changes that could be made to speed things up and optimize the script as well. Replacing the appropriate sections of course.
Change from copy to Xcopy:
xcopy /S /Y "D:\GOES DATA CENTER\goes16\fd\CUSTOMLUT\%starttime%\*.jpg" "D:\TEMPPROCESSING\GOES16Web_video\"
xcopy /S /Y "D:\GOES DATA CENTER\goes16\fd\CUSTOMLUT\%midday%\*.jpg" "D:\TEMPPROCESSING\GOES16Web_video\"
xcopy /S /Y "D:\GOES DATA CENTER\goes16\fd\CUSTOMLUT\%filetime%\*.jpg" "D:\TEMPPROCESSING\GOES16Web_video\"
xcopy /S /Y "F:\Satellite Imagery\goes16\fd\CUSTOMLUT\%filetime%\*.jpg" "D:\TEMPPROCESSING\GOES16Web_video\"
USING VARIABLES
set "IMAGEMAGICK=C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\magick.exe"
set "SOURCE_DIR=D:\TEMPPROCESSING\GOES16Web_video"
set "DEST_DIR=D:\TEMPPROCESSING\GOES16Web_video\AUTORESIZE"
for /r "%SOURCE_DIR%" %%a in (*.jpg) do (
"%IMAGEMAGICK%" mogrify -path "%DEST_DIR%" -type TrueColor -filter Triangle -define filter:support=2 -thumbnail 1800 -unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -strip -gravity south -stroke none -pointsize 28 -fill orange -font Ailerons -annotate 0 %%t "%%~a"
)
Here’s what was changed:
The ImageMagick path and source/destination directories were stored in variables to make it easier to change them if needed.
The for loop was simplified and the ImageMagick command was moved inside the loop. This way, the command is only executed once for each file, rather than launching ImageMagick for every file in the directory.