page collection. Back to:
This page lists common requirements for making AVIs on Linux systems.
, and explains my method. There are certainly many ways to accomplish the same outcome.
The overall procedure for encoding a movie goes like this:
Step 0: Locate the ROM necessary for the playback of the movie, and download the movie file.
Create initial encoding
Step 1: Run a script that launches the emulator and runs the movie.
The script will instruct the emulator to launch MEncoder, to create an
initial encoding of the movie. That initial encoding is labelled as
test0.avi, and it is at a nearly lossless quality. It is not distributed or uploaded to the TASvideos site, but it is the basis for further encoding passes.
Create subtitles for the movie
Step 2: Run a script that reads the movie file and creates a template for the subtitles of this particular movie.
The script will read the frame count and authorship information from the movie file specified, and output a subtitle file (
test0.sub) in which that information is denoted.
Step 3: Edit the subtitles.
Adjust the timings of the subtitles, and correct the game name and authorship, as necessary.
For example, for
this particular movie, the subtitles created by the script are as follows:
{60}{180}Adelikat, Deign, Cardboard, JXQ|Played by ?|Playing time: 0:47:33.52|Rerecord count: 78061
{192}{312}This is a tool-assisted recording, played on an emulator.|For details, see http://TASvideos.org/
I changed them as follows:
{120}{240}Super Mario Bros 3 without flutes|Played by Adelikat, Deign, Cardboard, JXQ|Playing time: 0:47:33.52|Rerecord count: 78061
{252}{372}This is a tool-assisted recording, played on an emulator.|For details, see http://TASvideos.org/
The list of changes I did are:
- Made the subtitles appear 1 second later so they won't pathologically overlap with the encoding logo / game title.
- Moved the author names after the "Played by " text
- Added the movie description.
Adjusting the encoding script for the movie
Step 4: Specify encoding parameters
My actual encoding script (after the initial encoding) consists of two components:
- nesvideos.cfg, which configures the encoding
- ENCODE, a shell script that does the actual bulk of the encoding work.
A sample script looks like this:
BR=240
QSCALE=32
FILES="test0.avi"
OTHER="$OTHER -endpos 49:49"
FINAL="supermariobros3-tas-warpless-adelikat,deign,cardboard,jxq.avi"
In this file, I have determined that the target bitrate for the video will be about 240 kbit/s, and that only the first 49:49 of the movie will be encoded, discarding the rest.
Run the encoding
Step 5: Launch the encoding
After steps 0-4 are done, it is time to launch the encoder.
It is done by executing the
ENCODE script.
Do not click it open from some desktop icon. Instead, use your terminal (all of this so far should have been done in one terminal), go to the directory where your
nesvideos.cfg and
test0.avi files are, and execute the
ENCODE script by giving its relative path.
In my system the paths work as follows:
- $HOME/nes/fceu: This is the directory where the initial encoding takes place. It contains the ROM, the movie file, and the RUNEMU script.
- $HOME/nes/xgetimage: This is the directory where the subtitle generator (GENSUB) and encoder (ENCODE) scripts reside.
- $HOME/nes/xgetimage/smb3: This the directory where the bulk encoding work happens. After the initial encoding, I have moved the test0.avi into this directory.
So the work so far is like this:
cd ~/nes/fceu
## Acquire movie file:
wget http://tasvideos.org/fcm/123456.zip
unzip 123456.zip
rm 123456.zip
## Change the filename to be easier to handle
mv 'Weirdly named movie file.fcm' smb3u.fcm
## Run initial encoding
./RUN smb3u.fcm smb3u.nes
## Initial encoding done, start actual work
mv test0.avi ~/nes/xgetimage/smb3/
cd ~/nes/xgetimage/smb3
## Generate subtitles (note the relative path):
../GENSUB ~/nes/fceu/smb3u.fcm
joe test0.sub # Note: joe is an editor.
## Check encoding settings:
joe nesvideos.cfg # Use nano/joe/vi/emacs/whatever.
## Start encoding. Note the relative path.
../ENCODE
## Done!
After this work, check out the working directory. The newest AVI file in that directory should be your produced AVI file.
- If errors happened, diagnose and fix them and try again.
- If the AVI quality is unsatisfying, remedy the problem and try again.
Alt Step 5: Creating an MKV file using x264.
To make an MKV file using x264 you will need to first decode the video using mencoder and pipe the raw video through a named fifo to x264, you must do this because x264 does not support avis input under Linux (you will probably want to change the bitrate to something appropriate for the game. Here is a command that will do just that. (This is tuned to NES video settings for pass 1 as an example)
mkfifo s.log ; mencoder -nosound -vf format=i420 -ovc raw -of rawvideo \
-ofps 60.100 -o s.log -quiet "mixed.avi" & x264 s.log --pass 1 --slow-firstpass \
--preset placebo --bitrate 300 --keyint 300 --fps 60.100 --output "encoded.mp4" \
256x224 ; rm s.log
Then you will need to pull out the audio and re-encode the audio as ogg.
mplayer mixed2.avi -ao pcm:file=encoded.wav -vc dummy -aid 1 -vo null ; oggenc -q1 encoded.wav
And finally you'll want to zip the two files together into an mkv. (You may need to download the source and compile it yourself if your version is old and does not support the no_simpleblocks hack. The source can be obtained through git,
git clone git://git.bunkus.org/mkvtoolnix.git)
mkvmerge --engage no_simpleblocks -o final.mkv encoded.mp4 encoded.ogg
EmulatorResources/MakingAVI/Common/Linux last edited by
OmnipotentEntity on 2009-09-22 08:49:14
Page info and history | Latest diff | List referrers