Creating a Worms movie/Batch exporting video frames

From Worms Knowledge Base

Jump to: navigation, search

By using a Windows batch file you will be able to automate the process of exporting video sequences from all of your chosen Worms Armageddon replay files. The advantages of this method:

  • It lets you skip the tedious form filling of the "Export video..." dialog.
  • If most of your video sequences are going to use the same resolution, you won't need to re-enter the parameters for any of those.
  • It will export all video sequences in a row, allowing you to leave the PC on and do something else in the meanwhile.

Batch exporting uses a new command line feature introduced in the v3.6.30.0 Beta (Oct 26th 2010), and it won't work with older updates.

The script

You can create a Windows batch file using the code below. The script was tested under Windows XP and Windows 7, but should also work under 2000/NT and Vista.

Make sure you edit the second line to include the exact path of your WA.exe file.

@ECHO OFF
SET WA_PATH=C:\Team17\Worms Armageddon\WA.exe

echo TWO-STEP BATCH W:A VIDEO EXTRACTION.
IF NOT EXIST filelist.txt GOTO NO_STEP_B
IF EXIST filelist.txt GOTO CHOOSE_STEP

:NO_STEP_B
echo A) Get the list of all the replays present in this folder (it will be saved in filelist.txt) with video extraction options.
GOTO VIDEOLIST

:CHOOSE_STEP
echo A) Create a new list (saved in filelist.txt) of all the replays present in this folder with video extraction options.
echo B) Export video using the given options from all the files gathered in the replay list.
SET /p WA_STEP= Choose which step to take [A,B]:
IF /i '%WA_STEP%'=='a' GOTO VIDEOLIST
IF /i '%WA_STEP%'=='b' GOTO EXPORT
GOTO CHOOSE_STEP

:VIDEOLIST
SET WA_FRAMEDIVIDER=1
SET WA_WIDTH=1024
SET WA_HEIGHT=768
SET WA_BASENAME=video_
SET WA_CHOSEN=n
SET WA_MANUALLY=n

echo.
echo Default video extraction template: 
echo - framerate divider = %WA_FRAMEDIVIDER%
echo - resolution = %WA_WIDTH%x%WA_HEIGHT%
echo - basename = %WA_BASENAME%
echo.
echo Use this template?
echo (Otherwise you'll be prompted for custom values)
SET /p WA_CHOSEN= [y,n]: 
IF /i '%WA_CHOSEN%'=='n' GOTO DEF_PARAMETERS

:BROWSE
echo.
echo Specify extraction parameters for each replay individually?
echo (Otherwise you can just edit filelist.txt later)
SET /p WA_MANUALLY= [y,n]: 
IF EXIST filelist.txt del /q filelist.txt
dir /b *.WAgame > templist.tmp
FOR /F "usebackq delims=;" %%a IN ("templist.tmp") DO call :PROCESSING "%%~fa" "%%a"
del /q templist.tmp
echo.
echo File list saved.
GOTO GETRUNNING

:DEF_PARAMETERS
echo.
SET /p WA_FRAMEDIVIDER=Default Frame Rate Divider value? (leave empty for 1) :
SET /p WA_WIDTH=Default Video Width value? (leave empty for 1024) :
SET /p WA_HEIGHT=Default Video Height value? (leave empty for 768) :
SET /p WA_BASENAME=Default Basename value? (leave empty for video_) :
GOTO BROWSE

:GETRUNNING
echo.
IF /i '%WA_MANUALLY%'=='y' echo All parameters were entered manually. 
echo You can now edit filelist.txt manually if you want to adjust any options, and run this batch script later to extract video with those adjustments.
echo Do you want to start extracting video now?
SET /p WA_CHOSEN= [y,n]: 
IF /i '%WA_CHOSEN%'=='y' call :EXPORT
GOTO EOF

:PROCESSING
SET WA_STARTTIME=00:00
SET WA_ENDTIME=00:00
IF /i '%WA_MANUALLY%'=='y' call :PARAMETERS %2
echo %1 %WA_FRAMEDIVIDER% %WA_STARTTIME% %WA_ENDTIME% %WA_WIDTH% %WA_HEIGHT% %WA_BASENAME% >> filelist.txt
GOTO EOF

:PARAMETERS
echo.
echo Replay File:
echo %1
SET /p WA_STARTTIME=Enter a timestamp to START extracting video from this replay: 
SET /p WA_ENDTIME=Enter a timestamp to END video extraction: 
SET /p WA_WIDTH=Enter a Width value for these video frames (leave empty for %WA_WIDTH%): 
SET /p WA_HEIGHT=Enter a Height value for these video frames (leave empty for %WA_HEIGHT%): 
SET /p WA_BASENAME=Enter a filename prefix for the video frames files (leave empty for "%WA_BASENAME%"): 
GOTO EOF

:EXPORT
echo.
echo Starting video extraction...
FOR /F "usebackq delims=;" %%a IN ("filelist.txt") DO "%WA_PATH%" /getvideo %%a
echo ...finished.
PAUSE
GOTO EOF

:EOF

Copy this code into a new text file, and save it with a bat extension (i.e. wormsvideo.bat).

How to use it

  1. Create a new folder.

    Note: It's recommended that you create it under \User\Games, as this seems to prevent an "unknown parameter" problem in the video-extracting stage.

  2. Copy your batch file in it, together with all of your desired replay files.
  3. Run the batch file. Follow the instructions. It will create a text file called filelist.txt, containing the list of replay files in the folder and the video extraction parameters for each.
  4. It will prompt you to start extracting video. If you haven't entered details for each file manually, you can do it now by editing filelist.txt. When you're ready, go ahead with the video extracting step.

Once it finishes exporting, all your video sequences will be saved under User\Capture as usual.

Personal tools