MAME Movie Maker Documentation

About MAME Movie Maker

Setup for Movie Making

Command-line Options Pertaining to MMM

Troubleshooting MMM

About MAME Movie Maker


In 2004 an idea was presented to the BYOAC message boards by a user named Trimoor. His idea was to use MAME's screen shot capability to take a series of screen shots, one for each frame of a running game, and then somehow combine those screen shots into an AVI file. These AVI movies would be viewable with any application which can play movies, such as Windows Media Viewer and so forth. More interestingly, many so-called "front end" applications have the capability of playing movies. Trimoor's idea was to generate a series of these movies and have the front end play them during game selection.

Having front end applications display movies was not a new idea. There was already an existing set of movies floating around on BitTorrent. I downloaded several of these and I decided to implement Trimoor's idea since it was a much better solution.

In addition to the series of screen shots, BuddaMAME generates a .wav sound file which contains the sounds of the movie, and a .vdb file. This .vdb file is passed to a program called VirtualDub. VirtualDub takes the audio and video files and creates the .AVI file.

Without the aid of another BYOAC member, Silver, I would have not been able to create this utility.

Setup for Movie Making


MAME Movie Maker is designed to be used as a batch process. For those unfamiliar with batch processes, I have created a way to automatically generate the batch process.

You will need two batch files to create movies. The first, which I have named batch.bat, will create a movie for the specified game. The second, which I call makemovies.bat, will call the first batch file with the necessary parameters which differ from game to game. You, of course, can name your batch files anything you want. I created both batch files in the same directory where the BuddaMAME executable resides.

Before anything else, you will need compression-decompression software (a codec). MMM supports codecs known as DivX, Cvid, and Xvid. Best results are generally had with Xvid. Go to Xvid.org and get Xvid codec software if you do not already have it.

You will also need VirtualDub, a program which will take a sequence of screen shots and a sound file and create a movie. VirtualDub will call the codec software for audio and video compression. Get the latest version of VirtualDub and install it into the \virtualdub directory on the same drive on which you have BuddaMAME installed.

Here's what my batch.bat looks like:

@if not exist movies mkdir movies
@if exist movies\%1.avi goto end
@if exist nvram\%1.nv goto rungame
@mame %1 -window -noartwork -resolution %2 -nothrottle -ftr 100
:rungame
time /T
@mame %1 -window -noartwork -makemovie -resolution %2 -wavwrite %1.wav -movieloops %3 -moviestartframe %4 -movieendframe %5
@if not exist %1.vdb goto end
@\virtualdub\vdub /s"%1.vdb" /x
@del %1.wav
@del /Q moviesnp\*.png
@del %1.vdb
@move /Y %1.avi movies
time /T
:end

Parameters to the batch file are as follows:
%1 Rom name
%2 Resolution of game
%3 Movie loop detection algorithm
%4 Starting frame for movieloops 2
%5 Ending frame for movieloops 2

Line-by-line description of batch.bat:

@if not exist movies mkdir movies
This line creates a directory for the movies if one does not yet exist.

@if exist movies\%1.avi goto end
If the movie exists, don't make the movie over again. This line makes it safe to interrupt the batch process if you wish to do something else with the computer. Since the entire set of movies will take several days to complete, this step is useful to have.

@if exist nvram\%1.nv goto rungame
If the current game has ever been run before, this step will skip down to the "rungame" label. Many games do not work correctly the first time they are run and need to be reset. If the game has never been run before, the following step will run it:

@mame %1 -window -noartwork -resolution %2 -nothrottle -ftr 100
This step will run the given game (%1), but will only run it for 100 frames, and as fast as possible. Games that have NVRAM or that don't run correctly the first time they are run will benefit from this step.

time /T
Display the current time.

@mame %1 -window -noartwork -makemovie -resolution %2 -wavwrite %1.wav -movieloops %3 -moviestartframe %4 -movieendframe %5
This line is the heart of the entire batch file. This line calls MAME with the correct resolution (%2 parameter). The -movieloops parameter, as explained below, determines the what method of loop detection MMM will take. %3, %4, and %5 can safely be set to 1, 0, and 0 respectively.

@if not exist %1.vdb goto end
This line of the batch file will skip to the end if the .vdb file is not created. VirtualDub will display an error if it is called with a non-existent script file, so this line is necessary to not stop the batch process if this happens.

@\virtualdub\vdub /s"%1.vdb" /x
Call VirtualDub to create the movie.

@del %1.wav
@del /Q moviesnp\*.png
@del %1.vdb

Clean up the .wav file created by BuddaMAME, the movie snapshots, and the VirtualDub script file. If you use a different directory in which to create the movie snapshots (-moviesnap_directory), then you'll need to edit this part of the batch file.

@move /Y %1.avi movies
This line moves the completed movie into it's final destination. When I ran this process, I put the movies into a separate directory on a different drive, so I had e:\movies here and where the directory is created.

time /T
:end

Display the current time and terminate.

Command-Line Options for MMM


Here are the options I have added to BuddaMAME which deal with creating attract mode demo loops. It is safe to put all these options except -makemovie in the mame.ini. You should only put -makemovie on the command line, because the movie making process is time-consuming and causes MAME to run much more slowly than usual. The center value in the table is the default value. The defaults work for the great majority of games. You might adjust the value of minmoviestart, minmovielength, or maxmovielength.
-[no]makemovie 0 Create series of snapshots and terminate MAME when a loop is detected
-moviesnap_directory moviesnp directory for movie frames (.png format) (default moviesnp)
-minmoviestart 200 Lowest possible start frame of movie
-minmovielength 800 Lowest possible movie length (in frames)
-maxmovielength 10000 Highest possible movie length (in frames)
-moviethreshold 2 Lowest 8-bit value for non-black pixel
-movieaudio 1 Movie audio compression type 0=none, 1=mp3, 2=custom
-movievideo 3 Movie video compression type 0=none, 1=divx, 2=cvid, 3=xvid, 4=custom
-movieloops 1 detect attract mode loops in movies, 0=disable, 1=duplicate frames, 2=fixed frame numbers, 3=debug, 4=start loop in middle
-moviestartframe 0 starting frame of movie (must use movieloops 2)
-movieendframe 0 ending frame of movie (must use movieloops 2)
-moviematchlength 10 number of consecutive matched frames which determine a loop
-movieskipblack 1 0=don't skip black frames 1=skip black frames 2=skip monochromatic frames (slower)
-movieskipframes 0 number of frames to skip at beginning of loop
-[no]moviesquare 0 Force the movie to be 256x256.

The -moviesquare option is useful for frontends which have the capability of treating AVI movies as image textures. Two of these are Dragon King and 3D Arcade. When viewing movies made with this option in a standard movie viewer, the aspect ratio of the movie may be off. It's the front end's job to correct the aspect ratio.

The -movievideo option defaulted to 1 prior to the release of BuddaMAME version 0.98. It now defaults to 3.

Troubleshooting MAME Movie Maker


If you have a batch file set up as described, it should be easy to diagnose any problems.

For starters, create a simple makemovies.bat which has only one line in it:

call batch gridlee 1 0 0

Set up your batch.bat file as depicted above. For simplicity, make all your directories on the same drive as your makemovies.bat.

In batch.bat, where the batch file deletes the temporary files, such as the .wav sound file and the .vdb VirtualDub script file, put the three characters REM in front of the command, this will cause the delete commands to not be executed:

rem @del %1.wav
rem @del /Q moviesnp\*.png
rem @del %1.vdb

Remove the at-sign (@) from the beginning of each line. The @ causes Windows to not print out each line of the batch file. This will allow you to better see what is going on.

Run makemovies.bat from the command line:

makemovies

If you get "Bad command or filename" on the \virtualdub\vdub step, then you either have not installed VirtualDub, you have it installed in the wrong place, or you have an earlier version. Only the most recent versions have the vdub.exe executable file, which is the version of VirtualDub designed to run from a command line.

When I ran this batch file for Gridlee, it resulted in a movie of approximately 1.3 megabytes. If you have an extremely large file, more than 100 megabytes, then you either do not have Xvid software installed or you have a version of Xvid installed that MMM does not understand. MMM supports DivX or CVid format as well as Xvid. To create a DivX movie, change the -movievideo parameter to 1. To create a CVid movie, change movievideo to 2.

For advanced users, I have designed MMM to allow custom audio and video encoding. Please email me for help with this.