Emulator Resources / Making AVI / FCEU / Windows
This page is part of the
Emulator resources / Making AVI page collection. Back to:
<<
Emulator Resources / Making AVI / FCEU<<
Emulator Resources / Making AVI<<
Emulator Resources
This page explains how to take a FCM 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.
Table of contents [
expand all] [
collapse all]
Downloading
You will need to download the following.
All downloads can be found at
here
- 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 FCM in question and the proper ROM. (This does not explain how to get either of those :P)
Installing and Configuring
- FCEU,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.
- Afterward, you will need to configure ffdshow to use "h264 lossless" as its default codec. Using h264 in this manner will allow you to use Virtualdub in the encoding process (among other advantages).
- 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 FCEU and then open the appropriate ROM.
- Press the "=" key to turn the emulation speed up to about 400%. This will blaze though the movie (depending on your processor's speed), but will produce a normal speed AVI. This will cut significant time off of the encoding process.
- Go to config > sound. Select 48000 hz for rate and Turn the volume bar all the way up.
- A 48000 hz sample rate for the initial capture is important because it will increase the overall subjective quality of the audio in the final product.
- Turning up the volume is important on FCEU .15 because, unfortunately, the volume bar affects the output volume of the AVI. (Hopefully this will be fixed in future FCEU versions).
- Pause the emulator (the default key for pausing is the "pause/break" key, but this can be configured under Config > Map Hotkeys).
- Navigate to File > Replay Movie and select the FCM.
- After the FCM is loaded, navigate to File > Record AVI. 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 and then unpause the emulator. FCEU should begin playing the FCM 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, volume, and emulator speed configurations all are saved by FCEU. Make another folder with FCEU that you use only for encoding so that you will not have to alter these settings. You can also bind hotkeys to replay movie and record AVI, if desired.
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.
Common errors to look for:
- Black screen for video. This is a bug that occurs in FCEU 0.98.16 and 0.98.13. Chances are have one of these versions of FCEU. Redownload the latest version. If it still persists, make sure you have the right codecs and an up-to-date media player.
- Audio "drift". Audio drift is when the audio progressively desynchronizes from the video. This is especially common in FCEU 0.98.12. Again, make sure you have the right FCEU version (0.98.28). If the audio drift continues, it can likely be fixed by doing the following:
- Open Virtualdub and navigate to Video > Framerate. Then select "Change so video and audio durations match". Then go to Video > Compression and select ffdshow as your codec. Finally, go to File > Save as AVI. (This can all be done at the same time as cropping/editing). Hopefully this will fix the drift.
Cropping & making subtitles with Virtualdub
Open up the captured AVI with virtualdub.
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.
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.
Now that your movie 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 recorded.avi and save it to the Mencoder folder.
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 NES 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 48khz, monaural sound.
- The AVI must be 60 frames per second (fps).
- Must have a screen resolution of 256x224.
- Must be encoded using H.264 lossless. This can be done via ffdshow in virtualdub, or x264 with the quantizer set to 0.
We will use Mencoder to add the logo.
Note: Unfortunately FCEU/NES runs at a framerate of approximately 60.1 fps. As such, adding the logo via Virtualdub and "append AVI segment" doesn't work (for me at least. If you manage to get that to work let me know how).
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.
Place your logo in the Mencoder folder and name it logoNES.avi (filenames of course can be changed, just remember to change them in the batch files as well). Copy and paste the following into notepad and name it mix.bat.
start /wait mencoder.exe -priority idle -oac copy -mc 0 -ovc lavc -lavcopts vcodec=ffv1:vstrict=-2 -o mixed.avi logoNES.avi recorded.avi
Then go to the Mencoder folder and double click the batch file to execute the commands within it.
Note: This uses a different lossless codec for the AVI and results it a very large file. Unfortunately, this pass and the next audio pass will be about 1 GB in size, which could be a problem if you are short on hard drive space.
It could be kept at a reasonable size by using h264 with the following command:
start /wait mencoder.exe -priority idle -oac copy -mc 0 -ovc x264 -x264encopts qp=0 -o mixed.avi logoNES.avi recorded.avi
However, this can result in some nasty video artifacts. (If you find a way to use h264 for the mix without video artifacts, please let me know.)
Run the resulting batch file. This process should take a few minutes - it runs at about 180-240 fps on average on my 3.4 ghz processor.
Audio compression
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=40:aq=0:mode=3 -ovc copy -o mixed-a.avi mixed.avi
Important things to know:
- preset=40 – This is the Average Bitrate setting. Raising or lowering this will increase/decrease the audio quality. For NES games I have rarely altered this number, but you may want to experiment with it.
- mode=3 – This sets the sound mode to monaural. NES and SMS are the only platforms that are mono. This setting would need to be changed to mode=0 for stereo if this is to be run on a different platform that supports stereo sound. 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
(Add brief explaination of multi-pass encoding here)
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 all these command lines into a single batch which is called Mix-NES.bat on my computer. This combines the logo mix, 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=250:pass=3:frameref=15:qcomp=1:ratetol=100:me=3:me_range=32: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=250 - 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=32 - This number works for just about every NES game. However, raising this number might be necessary if the game has a lot of motion or unusually complex graphics. Raising the 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 Super Mario Bros. 2 (USA) which used a 170 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 NES games is generally somewhere between 175 to 275. Simpler games such as
A Boy and his Blob can be as low as 120. Games with hardly any motion such as
Déjà Vu can be as low as 60!
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=220:pass=3:frameref=15:qcomp=1:ratetol=100:me=3:me_range=40: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=200:pass=3:frameref=15:qcomp=1:ratetol=100:me=3:me_range=40: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=180:pass=3:frameref=15:qcomp=1:ratetol=100:me=3:me_range=40: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=160:pass=3:frameref=15:qcomp=1:ratetol=100:me=3:me_range=40: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 NES 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 NES games, that won't be an issue. Most NES encodes will be between 1 and 2mb/minute. If you used a bitrate under 300, yet your file is larger than this ratio, you should double check your encoding process.
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
- The audio is too quiet (usually resulting from the volume control of FCEU being set low, or audio drift.
- Audio drift is where the audio is progressively more offset from the video. This should have been noticed and correct prior to encoding. This can often be fixed, see "Capturing".
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.
EmulatorResources/MakingAVI/FCEU/Windows last edited by
FractalFusion on 2008-09-03 08:11:42
Page info and history | Latest diff | List referrers