Gens Re-Recording

From Sega Retro

Gens Movie Test is a modification of the highly popular Gens emulator by Stéphane Dallongeville (also known as Stef). This modification includes slowdown, recording and playback of controller input logs, and dumping of AVI files. This emulator is primarily used by the Nesvideos community.


Creating DVD-compliant video from emulator output on Windows

It is easily possible to create 100% DVD compliant video from the 320x240 Gens Movie Test raw emulator output. This requires Avisynth, the MPEG-2 encoder of your choice - this editor recommends TMPGEnc (but you can use any MPEG-2 encoder as long as it properly supports interlaced video) and AC3Machine (using BeSweet as it's AC3 encoder). This can also require lots of hard drive space depending on the length of the movie. This guide is primarily concerned with NTSC video, but can be easily modified to generate PAL instead, although I haven't done so myself.

Generating the raw AVI

First of all, load Gens Movie Test and load your ROM. Next, press ESC to pause the emulator. Go to the following menu items and select them:

  • Graphic -> Sync AVI with movie
  • Graphic -> Add sound to AVI
  • Graphic -> Start AVI Dump
  • Graphic -> Frame Skip -> 0
  • CPU -> Play Movie/Resume record from savestate
  • (optional) Option -> Misc... enable Show frame counter, Show input, and choose a position (I recommend lower-right)

In the dialog that appears, browse to find the GMV file that you wish to use as your source, and ensure that Play from start is selected. Press OK. Whenever you're ready to begin dumping the AVI, press ESC once more, and choose a lossless codec (I use the Camstudio Lossless Codec in GZIP compression at level 9, but a codec like Huffyuv will work just as well). When the movie is finished playing back, select Graphic -> Stop AVI Dump and exit the emulator.

Conforming the raw AVI to NTSC DVD specs

At this point you will likely have multiple AVIs that are around 1GB apiece. Use the following script (place it in the same folder as your raw AVIs and give it the same name but with an AVS extension):

AVISource("gens.avi")+AVISource("gensA.avi")+AVISource("gensB.avi") # make sure you put all your AVIs here in order
AssumeBFF()
AssumeFieldBased()
Crop(1,0,0,0) # remove garbage pixel on left
#PointResize(638,240) # this is for 'perfect' video
BilinearResize(638,240) # this is for video that looks closer to a real RGB output
AddBorders(42,0,40,0) # pad to 720x240
Weave() # weave fields into 720x480 frames
AssumeFPS(29.97,true) # adjust framerate from 30fps to 29.97fps for NTSC
ResampleAudio(48000) # fix the audio sample rate from the framerate modification

To visually inspect the output of this script, you can use VirtualDubMod, although you won't have to render video with it if you are using TMPGEnc to encode your video. You should see video that is 720x480, that exhibits 'mice teeth', and depending on which resize method you used, video that looks slightly soft in the horizontal direction.

Encoding to MPEG-2 with TMPGEnc

This guide assumes you are using TMPGEnc, which can directly accept AVS files for input. If you are using an MPEG-2 encoder that does not, then you will have to use VirtualDubMod to render the AVS script to another AVI file, which should also be lossless. The general settings for the MPEG-2 encoding should be applicable to other encoders, however. In TMPGEnc, I recommend not using the wizard mode, and instead, finetuning the encoding parameters yourself. First of all, in assuming you want the best quality, I recommend using a Constant Bit Rate of 8000kbps for the video, unless the video is longer than an hour or so. You'll be u sing LPCM in TMPGEnc, which you'll encode to AC3 later.

Video tab:

  • File -> New Project
  • Load the AVS with Video source at the bottom of the window
  • Choose ES (Video+Audio)
  • Press Setting
  • Stream type -> MPEG-2 Video
  • Size -> 720x480
  • Aspect Ratio -> 4:3 Display
  • Frame Rate -> 29.97 fps
  • Rate control mode -> Constant bitrate (CBR)
  • Bitrate -> 8000 kbits/sec
  • Encode mode -> Interlace
  • DC component precision -> 10 bits
  • Motion search precision -> Motion estimate search (fast)

Advanced tab:

  • Video source type -> Interlace
  • Field order -> Bottom field first (field B)
  • Source aspect ratio -> 4:3 525 line (NTSC)
  • all other options on this tab disabled

GOP Structure tab:

  • Number of I picture in GOP -> 1
  • Number of P picture in GOP -> 17
  • Number of B picture in GOP -> 0
  • Output interval of sequence header -> 1
  • MAX number of frames in a GOP -> 18
  • Detect Scene Change

Audio tab:

  • Stream type -> LPCM
  • Sampling frequency -> 48000 Hz
  • Channel mode -> Stereo

Press OK. Go to Output file name, press Browse, and choose a filename for your encoded output (it will automatically generate both .m2v and .wav files with that name). Press Start at the top and go out for a meal, because it will take a good while to encode.

Encoding the audio to AC3

All players will support both LPCM and AC3 audio, but LPCM is also much larger. Instead, we will be making a 448kbps AC3 file. Load AC3 machine, select your input .wav file and and output .ac3 file.

  • Channels Mode -> stereo
  • Auto Find Maximum Gain
  • Set delay to 0 msecs
  • Bitrate -> 448

Now press Give me AC3! and wait a little bit (this will take far less than the video encoding did). Once it's done, you should have both an .m2v and .ac3 file.

Authoring the DVD

This is the part where it really doesn't matter so much what DVD authoring tool you use, I use TMPGEnc DVD Author but as long as it accepts m2v and ac3 input then you're good to go, and you can set up menus as you like. Since all DVD authoring tools are different, I won't even get into describing how to do it, but at this point, if you've authored other DVDs before, then you just do the same thing that you'd be used to doing.