Emulator Resources / Making AVI / Gens / Windows

This page is part of the Emulator resources / Making AVI page collection. Back to:
<< Emulator Resources / Making AVI / Gens
<< Emulator Resources / Making AVI
<< Emulator Resources

This page explains how to take a GMV file and convert it to a TASvideos.org quality AVI file suitable for publicaton.

This was written by me, adelikat, and explains my method. There are certainly many ways to accomplish the same outcome.

I tried to streamline my process and explain it in a comprehensive way, and include potential mistakes and other problems that I and others have run across.

Downloading

You will need to download the following. All downloads can be found at here

  • The latest GENS rerecording: GENS10
  • x264
  • ffdshow
  • virtualdub
  • mencoder
  • All of these can be found at here
    • Note: Most of these are older versions. Newer versions will probably not work with this tutorial.

  • And, of course, the GMV in question and the proper ROM. (This does not explain how to get either of those :P)

Installing and Configuring

  • GENS,virtualdub,mencoder - simply unzip the ZIP file
  • The MEncoder will unzip Mencoder, Mplayer, subfont.tff, and a folder of all .bat's used on this page.
  • X264 will need to be unzipped and the installed.
  • ffdshow - you will need to run the installation program. During installation, install all components. For "select supported video codecs", make sure to select H.264. The rest of the options should be left to the default.
    • After installing, go to the start menu > ffdshow. Select VFW codec configuration. Under the encoding tab, select "H.264 lossless". Under FOURCC, select H264. Other settings can be left on default. Select the Decoder tab now, and click Codecs in the left hand list. A new menu should now appear. Find H.264 in the list and set it to libavcodec by clicking on it in the decoder column.

With all of this configured, you are now ready to capture!

Capturing

The most important part of the encoding process is getting an initial lossless AVI. Any problems in the original capture will only compound during the compression process, resulting in either a lower fidelity in video/audio, or a higher file size.

  • Obviously you need to open GENS and then open the appropriate ROM.
  • Turn off Vsync by going to Graphic > Vsync (or Shift+F3), and set frameskip to 0. This will turn of the 60fps limiter and allow the movie to play at the fastest speed your computer will allow. This will reduce the capture time (probably a bad idea if you want to watch the movie too).
  • Go to config > sound. Select 44100 hz for rate (should be set there by default).
  • Pause the emulator (the default key is the "Esc" key)
  • Go to options > General. Uncheck "show frame counter", "show lag frame count", and "show input".
  • Navigate to Tools > Avi options > Add sound to avi
  • Navigate to Tools > Movie > Play Movie and select the GMV.
  • Navigate to Tools > Movie > Start AVI dump and unpause. Select a folder to save the file (the Mencoder folder might be convenient). A video compression menu will pop up. Select ffdshow in the drop down menu. (Note: you don't need to configure anything since you already did so earlier.) Press OK. GENS should begin playing the GMV movie, and capturing the result into an AVI.
  • Let the movie play completely and through all the end credits. If the game gets to an ending screen and loops the music endlessly, let the music play though at least 1 complete cycle (within reason). If you are not sure when to stop it, err on the side of making the encoded AVI longer, as you will have the opportunity to crop it later.

  • Tip: The sound rate, Vsync, and display configurations all are saved by GENS. Make another folder with GENS that you use only for encoding so that you will not have to alter these settings.
That's it! You are done capturing a nice lossless AVI ready for editing and compression.  At this point open the AVI and check it.

You want to check to make sure there is both video and sound, that the sound syncs with the video, and that the video quality is "lossless".

Logo

A published AVI file on TASvideos.org needs a good logo. There are strict requirement on the content of a logo, explained on the Logo page. All logos must be approved by Bisqwit before publication.

In addition, your GENS logo must meet these specific requirements:

  • It must have an audio track and that track must be only silence.
  • The audio track must be at a sample rate of 44.1khz, stereo sound.
  • The AVI must be 60 frames per second (fps).
  • Must be a screen resolution of 320x240
  • Must be encoded using H.264 lossless. This can be done via ffdshow in virtualdub, or x264 with the quantizer set to 0.

Adding the logo, cropping & making subtitles with Virtualdub

Adding the Logo

Open your GENS logo .avi with Virtualdub. Then navigate to File > Append avi segment. Select the inital capture .avi. This combines the logo and the initial capture.

Cropping

If you did not stop the initial capture in the right spot, now is the time to crop the ending. Simply scroll to the end of the movie and find the frame you wish it to end. If the movie has a clear end (like a fadeout to a black screen or the opening of the game), then crop it there. If there is a "The end" screen that loops music continuously, make sure that the music completes a cycle. Once you have the movie set to the frame you wish to end it, press the "home" key. Then scroll to the end of the movie on the timeline/bar and press the "end" key. Finally, press "delete" key to remove the selected segment from the movie.

Making a subtitle file:

This is the best time to do this since you have virtualdub open to easily scroll though and find good frames to begin and end the subtitles.

Here is a sample .sub file. For this encoding tutorial, you want to copy/paste this to notepad and create a file called test0.sub and place it in the mencoder folder.

{60}{360}Super Mario Bros.|played by klmz|Play length: 04:48.53|Rerecord count: 4459
{1501}{1701}This is a tool-assisted recording.|For more information, visit http://tasvideos.org/

  • Tip: After saving the file, right-click it and select properties. Under "Opens With" click Change, and select Notepad. Now you can simply double-click the file to remake for new encodes.
  • Change the movie information accordingly. All of this information is available on the submission page.
  • Be especially careful with the name of the game. If there is a previous publication of this game, make sure to use the previous spelling and format.
  • The numbers on the left of each line are the frame numbers that the subtitle line will appear and disappear. In Virtualdub, use the arrow keys to scroll through the movie to find a good place for the two subtitles. Each one should be left on the screen long enough to be read and the information should be presented prominently enough that it cannot be clipped out from the movie by video editing without extraordinary effort.

Now that your movie has a logo, is cropped, and a subtitle file is ready, navigate in Virtualdub to Video > Direct Stream Copy, and then File > Save as AVI. Name the file mixed.avi and save it to the Mencoder folder.

Audio compression

We will now be making several "Batch" files. These files consist of command line expressions that are run from a file, all at once. The file extension is BAT.

We will compress the audio using Lame via Mencoder.

  • Copy and paste this into a batch file and run it:

start /wait mencoder.exe -priority idle -oac mp3lame -mc 0 -lameopts preset=67:aq=0:mode=0 -ovc copy -o mixed-a.avi mixed.avi

Important things to know:

  • preset=67 – This is the Average Bitrate setting. Raising or lowering this will increase/decrease the audio quality. Many GENS games have a particularly large abundance of high frequencies in certain sound effects. Sometimes it is necessary to raise this amount.

  • mode=0 – This sets the sound mode to stereo. This is the case for all platforms other than NES and SMS (they would need to be changed to mode=3). If done improperly, this will clash with the logo file and can cause playback problems on certain media players (this has occurred in several TASvideos publications).

  • aq=0 – This is the quality vs processing speed control. 0 will result in the lowest file size but run the slowest. If it runs slow on your computer you may want to bump this to 1. The difference between the two settings is about an average of 100kb.

Video compression using h264 multi-pass

The first pass:

Copy and paste this into a batch file and run it.

start /wait mencoder.exe -priority idle -vf decimate=30:0:0:1 -aspect 4:3 -oac copy -mc 0 -ovc x264 -x264encopts pass=1 -o Video-comp-1stpass.avi mixed-a.avi -sub test0.sub -subfont-text-scale 4 -sub-bg-alpha 15 -font ./mplayer/subfont.ttf

Important things to know:

  • The first pass does not use advanced settings, so it is significantly faster than the next passes and does not require content-dependent altering.
  • -aspect 4:3 – This sets the aspect ratio. This is platform specific. It would need to be changed/removed depending on the resolution of other platforms.
  • turbo=1 – This can be added. It increases the speed of this pass but with a slight quality/size decrease in the final result. For me, the first pass runs fast enough without it, so it's not worth the quality loss. (My tests have shown too much a noticeable decrease in quality for my tastes.)

  • Time saver: I combine both of these command lines into a single batch which is called Mix-GENS.bat on my computer. This combines audio pass, and first video pass into a single step. I have a separate Mix.bat for each platform, so I no longer have to worry about platform specific variations.

Video Compression - Selecting Nth pass Settings

This is by far the most time consuming part of the encoding process. We will run the second pass with all the advanced/slow encoding settings, and we will have to do some trial and error to select an appropriate bitrate and other settings.

This is the basic command line for the second, third, and all remaining passes:

start /wait mencoder.exe -aspect 4:3 -vf decimate=30:0:0:1 -priority idle -oac copy -mc 0 -ovc x264 -x264encopts bitrate=400:pass=3:frameref=15:qcomp=1:ratetol=100:me=3:me_range=40:subq=7:8x8dct:mixed_refs:fast_pskip=no -o Video-comp.avi Video-comp-1stpass.avi -sub test0.sub -subfont-text-scale 4 -sub-bg-alpha 15 -font ./mplayer/subfont.ttf

This is probably confusing to someone unfamiliar with Mencoder commands. Here is a brief explanation of settings that need to be considered:

Things that might look odd:

  • pass=3 is correct even though this is the second pass. pass=3 simply sets Mencoder to "N-th pass" mode so that the temp log will track the stats for subsequent passes.
  • Adding the subtitle information again is not required since they were added in the first pass. However, the final file size will be a few kb smaller if they are added in this command line and it does not slow the pass down to add them.

Content dependent variations:

  • bitrate=400 - Every AVI will need a different number here. This is the most important setting an encoder will choose. We will find out how to get a good bitrate later.
  • me_range=40 - This number works for just many GENS games. However, raising this number is often necessary if the game has a lot of motion (such as Sonic games) or unusually complex graphics (such as Gunstar Heroes). Raising this setting can often lower the file size by a few kb in most games, but will significantly slow down the encode process. If you have the processing power or patience, you may want to experiment with raising this number. The maximum is 64.
  • trellis=2 – This can be added after :8x8dct. This will pack the bits tighter and results in about a 100kb smaller file on average. It noticeably reduces encoding speed. This might be necessary though if a game has a lot of motion/complexity and needs more extreme settings to meet site requirements.
  • me=3 – This will need to be changed to me=umh for newer versions of Mencoder.
  • me=3 – This can also be changed to me=4 (me=esa for newer versions) for more extreme movies. However this is VERY slow. My encodes go from about 15-20fps to 1/2 fps with this. It supposedly gives better results.
  • subq=7 – This can be changed to subq=6 for a much faster encode. This will nullify some of the more process-intensive settings in the command line, which will result in a larger overall file size. I don't recommend it for published AVIs but can be a nice feature for a quick encode.

Selecting a bitrate

The bitrate is the most important decision you have to make, and it unfortunately does not have a "one size fits all" type of solution. This is where is good encoder has to use his or her own experience to decide on a good encode. At first, it is mostly trial and error, but after some experience, an encoder can use knowledge of previous encodes to help with the decision. For example - "This movie is very similar to Mystic Defender which used a 550 bitrate, so I will try that first". Also, save the batch file you used for any published movie you encode, as well as the subtitle file. Often, movies get obsoleted, and you will already have all the settings you need for a new AVI when that time comes.

A good bitrate for GENS games is generally somewhere between 250 to 550. Simple games such as Dark Castle can be as low as 130. Games like Gunstar Heroes need as much as 750!

Here are some published movies and the bitrates I used to encode them:

Making samples

Since trial and error can get time consuming, it is a good idea to crop a short sample of the AVI and then try many bitrates on it.

Make a batch file with these commands:

start /wait mencoder.exe -priority idle -oac copy -ovc copy -ss 59 -endpos 00:01:00 -o Video-samp.avi mixed-a.avi

start /wait mencoder.exe -aspect 4:3 -vf decimate=20:0:0:1 -priority idle -oac copy -mc 0 -ovc x264 -x264encopts bitrate=500:pass=3:frameref=15:qcomp=1:ratetol=100:me=3:me_range=48:subq=7:4x4mv:mixed_refs -o Video-samp220.avi Video-samp.avi -sub test0.sub -subfont-text-scale 4 -sub-bg-alpha 15 -font ./mplayer/subfont.ttf

start /wait mencoder.exe -aspect 4:3 -vf decimate=20:0:0:1 -priority idle -oac copy -mc 0 -ovc x264 -x264encopts bitrate=450:pass=3:frameref=15:qcomp=1:ratetol=100:me=3:me_range=48:subq=7:4x4mv:mixed_refs -o Video-samp200.avi Video-samp.avi -sub test0.sub -subfont-text-scale 4 -sub-bg-alpha 15 -font ./mplayer/subfont.ttf

start /wait mencoder.exe -aspect 4:3 -vf decimate=20:0:0:1 -priority idle -oac copy -mc 0 -ovc x264 -x264encopts bitrate=400:pass=3:frameref=15:qcomp=1:ratetol=100:me=3:me_range=48:subq=7:4x4mv:mixed_refs -o Video-samp180.avi Video-samp.avi -sub test0.sub -subfont-text-scale 4 -sub-bg-alpha 15 -font ./mplayer/subfont.ttf

start /wait mencoder.exe -aspect 4:3 -vf decimate=20:0:0:1 -priority idle -oac copy -mc 0 -ovc x264 -x264encopts bitrate=350:pass=3:frameref=15:qcomp=1:ratetol=100:me=3:me_range=48:subq=7:4x4mv:mixed_refs -o Video-samp160.avi Video-samp.avi -sub test0.sub -subfont-text-scale 4 -sub-bg-alpha 15 -font ./mplayer/subfont.ttf

This will cut a 1 minute segment out of the 1st pass AVI, and then run passes with various bitrates common for GENS encodes. After running this batch file, watch Video-samp.avi. The cropping process often results in some blurring or artifacts in the first few seconds of the sample. You need to be aware of these spots when watching the compressed versions.

Watch each compressed sample and look for the lowest bitrate that is still of acceptable quality. Look for blurriness in the background that suddenly sharpens, or comes "into focus". This is a sign that a higher bitrate is needed. Look for excessive encoding artifacts around the main character. Look for overall blurriness. If there is a published AVI of this game, watch it and compare to your encode.

If the lowest bitrate sample looks lossless, you may want to try using an even lower bitrate. Similarly, if the highest still is too blurry or smeared, select a higher bitrate. If needed, run another set of samples with different values until you find an acceptable rate.

If this 1 minute clip looks good then the full AVI will likely look good as well. Of course, this is not guaranteed since later parts may have significantly different graphics and/or motion than the sample segment that was used for comparison.

Once you have the bitrate selected, plug it into your N-th pass batch file. Make any other needed setting changes as explained above, and then run the batch.

Running a third or fourth pass.

If the AVI created looks really good in some spots and really bad in others, it could benefit from a third pass. Simply run the N-th pass batch file again with the same settings. If you think the bitrate is too high or too low, you can change it slightly and run again.

However, if the resulting AVI is just far too blurry or requires significant setting changes, it's a good idea to restart the first pass AND second passes again, instead of trying a third pass.

A third pass (with identical settings) has much less of an effect on the subjective quality of the AVI than the second pass. A fourth pass is likely not going to give any noticeable effect, but in extreme cases might be helpful.

Double checking your AVI

The file size ratio must be good.

The site does not allow (without special permission) a filesize to length ratio greater than 4mb per minute. For GENS games, this can be an issue. Most GES encodes will be between 3 and 4mb/minute. If you used a bitrate over 500, it could exceed the 4:1 limit. In this case you want to try more aggressive settings (higher me_range, trellis=2, possibly lower audio bitrate). If the game is extraordinarily complex such as Rocket Knight Adventures or Gunstar Heroes then a publishable quality video will have to exceed this limit. Such movies can only be published with special permission from Bisqwit.

Video quality must be good.

This is subjective, but you want to look for background "refocusing" - where pieces of the background become blurry over time, and suddenly sharpen back into focus. Make sure there is detail in the backgrounds. Look for "streaking" of moving objects - where a moving object (such as the main character) leaves a trail behind him of blurry or different color background. Due to the use of h264, there will be some small artifacts on moving characters, as well as some slight blurriness of text. This is normal and acceptable in small quantities. However, if it is too blurry, then it needs to be encoded again.

Audio quality must be good.

Common audio problems include:

  • High frequency artifacts due to low bitrate. Especially problematic for Sega Genesis games because they tend to have a high amount of high frequency content. A higher bitrate will help.

Subtitles must be correct.

Double check that the subtitles have no errors (spelling or otherwise) and that the information is correct. Double-check that the subtitles are placed in a good spot. If you find an error at this stage, unfortunately, all video passes must be redone.

If all of these things check out well, then congratulations, you are finished! If you are a publisher, the next step is to review the PublisherGuidelines. If you are not, then you want to review the AVI file name section of the Publisher Guidelines, name the file appropriately (as a courtesy), then get the file into a publisher's hands.


Get Firefox!EmulatorResources/MakingAVI/Gens/Windows last edited by Raiscan on 2008-09-02 21:59:45
Page info and history | Latest diff | List referrers