View Full Version : Converting MAME MNGs to AVI

21st August 2009, 09:32 PM
I googled a bit and didn't manage to locate a decent (working) batch converter for the Crashtest set of MNG Videos. Oneday I'll grab an emumovies disc/access, until then this will do me. May not be much use to anyone, but is here for future reference.

It uses the first program to extract the frames from the MNG, then tells FFMPEG to encode the frames to a simple AVI at the original framerate with MP3 Audio. It is a basic conversion and ouputs compatible synced AVI files for use with MAMEWah.

Converting MAME MNGs to AVI

Tools Required:
FFMPEG (http://ffmpeg.org/)
ADVComp (http://advancemame.sourceforge.net/comp-readme.html), ADVMNG.EXE

I threw together this batch to convert a file passed to it (in windows), no error checking just straight at it


@echo off
setLocal EnableDelayedExpansion

REM #### Extract Frames from MNG ####
echo Extracting Frames from MNG
advmng --extract "%1.mng" >> "%1.frame"

REM #### Get Framerate from MNG ####
echo Reading Framerate Information
@for /f "tokens=* delims= " %%a in (%1.frame) do (
set framerate=%%a

echo Detected Framerate: %framerate%

REM Trimming Framerate to real number
for /f "tokens=1 delims=. " %%a in ("%framerate%") do set framerate=%%a

echo Using Framerate: %framerate%

REM #### Create Video From PNGs ####
@ffmpeg -threads 2 -r %framerate% -i "%1-%%08d.png" -vcodec mpeg4 -vtag XVID -i "%1.mp3" -acodec copy -y "%1.avi"

REM #### Clean up ####
echo Cleaning Up
del /Q "%1*.png" "%1.frame"

I then generated a second batch file from the MNGs to call the first file and convert. An example of the contents are here,


call batch D:\Emulators\mame\previews\ingame\1941
call batch D:\Emulators\mame\previews\ingame\1942
call batch D:\Emulators\mame\previews\ingame\1943
call batch D:\Emulators\mame\previews\ingame\1943kai
call batch D:\Emulators\mame\previews\ingame\1944

Throw all the batch files and required tools in one directory, edit the paths in MNGLIST.BAT so it points the MNG's then run MNGLIST.BAT. The conversion should run through all the found MNGs, creating the AVI and muxing the MP3 audio.

UPDATE: Tweaked BATCH.BAT file to avoid 0byte avis when source framerate is non-standard.

22nd August 2009, 02:47 PM
updated batch.bat to avoid errors seen on 65 of the files

22nd August 2009, 06:20 PM
Go go FFMPEG. Awesome bit of FOSS software.

25th November 2009, 09:42 AM
Thanks. Was wondering how to do this.