Post subject: Native Linux avi creation
Former player
Joined: 12/5/2007
Posts: 716
The contents of this post were lost in an unscheduled server reboot -- ...What?! Thank God I saved that huge post before... Hey there, I'd like to be able to create my own NES avis mainly for two reasons: first, I find it way more comfortable to watch a run in an avi/mkv/whatever because this way you can simply rewind the video for a few seconds to see something again. Secondly, I'd like to help these guys out. I've tried several versions now to create an avi off an .fcm-movie, but so far, no version worked for me. First of all, this is my RUN script:
#!/bin/sh
#
EXE=./fceu
#
# Which file do you want to place your audio and video in.
VIDEO_RESULT="./test0.avi"
#
SL="-slstartp 0 -slendp 239 -slstart 8 -slend 231 -no8lim"
#
#
VIDEO="-ovc x264 -x264encopts crf=0:me=dia:turbo=2:frameref=4"
AUDIO="-oac mp3lame -lameopts mode=3:preset=60:aq=0"
VIDEO="$VIDEO -vf decimate=10:0:0:1 -nocache"
VIDEO="mencoder \
- -o '$VIDEO_RESULT' \
mc 0 -aspect 4/3 \
NESVSETTINGS \
$VIDEO \
$AUDIO \
&> mencoder.log"
#
rm -f s.log
$EXE $SL -xscale 1 -yscale 1 -pal 0 -special 0 -soundq 1 -sound 48000 \
-no8lim 1 \
-videolog "$VIDEO" \
-nothrottle 0 \
$*
It's a bit different compared to the FAQ's version: First of all, I added -special 0, because I got a huge windows with virtually nothing in it before adding this parameter. Secondly, I removed the line about the color palette, because I can't seem to find this file anywhere and the colors look just fine for me when normally watching a run. To get the FAQ's source code compiled, I stripped -lirc and -lguide from the link command, because I can't seem to find these libraries either. After I got the source code compiled, I ran into the following (stripped my overly long directories):
$ ./RUN -play drmario.fcm drmario.nes 
Set clock rate. 1789772.7273; 29780.50 ticks per frame. Gain=1.4

Starting FCE Ultra 0.98.15...
NTSC selected
Loading drmario.nes...

 PRG ROM:    2 x 16KiB
 CHR ROM:    4 x  8KiB
 ROM CRC32:  ...
 ROM MD5:  ...
 Mapper:  1
 Mirroring: Horizontal

Initializing video... Video Mode: 256 x 224 x 32 bpp 

Initializing sound... (48000)
 Bits: 16
 Rate: 48000
 Channels: 1
 Byte order: CPU Native
 Buffer size: 1152 sample frames(24.000000 ms)
Blargg Init with rate 48000
Set clock rate. 1789772.7273; 29780.50 ticks per frame. Gain=1.4
s=12048, new_size=-67
Contemp=48000, Final=48000
Loading movie: drmario.fcm # submission #418
movie is version 2
Movie playback started.
Starting new AVI (num 0)
Launch: mencoder - -o './test0.avi' mc 0 -aspect 4/3 -audiofile ./s.log -audio-demuxer rawaudio -demuxer rawvideo -rawvideo fps=60.0998:format=0x30323449:w=256:h=224:size=86016 -rawaudio channels=1:rate=48000:samplesize=2:bitrate=96000 -ovc x264 -x264encopts crf=0:me=dia:turbo=2:frameref=4 -vf decimate=10:0:0:1 -nocache -oac mp3lame -lameopts mode=3:preset=60:aq=0 &> mencoder.log
At this point, nothing happens. A little FCEU window pops up, but it's just gray and can only be killed by pressing Ctrl-C in the terminal:
^CBlargg Init with rate 48000
Set clock rate. 1789772.7273; 29780.50 ticks per frame. Gain=1.4
s=12048, new_size=-67
Contemp=48000, Final=0

Signal 2 has been caught and dealt with...
How DARE you interrupt me!
$ cat mencoder.log 
MEncoder dev-SVN-r26753-4.1.2 (C) 2000-2008 MPlayer Team
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ (Family: 15, Model: 43, Stepping: 1)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2

Reading from stdin...
success: format: 0  data: 0x0 - 0x0
$
I am fairly sure my mencoder is alright, because I can create perfect SNES avis with it (yeah, the logo is missing, but who cares when you just want to watch it your own?). So after the FAQ's fceu didn't come up with something, I tried two other fceu binaries: 0.98.12 and 0.98.16.luke: watching a run works great, but -videolog seems to be ignored, although grep found the string "videolog" in .12's binary. Altough I'm well aware the software is provided as-is, any help is greatly appreciated. Also, I am in no way a C(++) coder at all and am only aware of the very basics of C. Some information that may be needed: Gentoo Linux Kernel 2.6.26 gcc 4.1.2 glibc 2.6.1 mencoder 1.0_rc2_p26753
Former player
Joined: 12/5/2007
Posts: 716
Well, the problem almost fixed itself. While I stripped the leading spaced for VIDEO (because I personally find it better looking if parameters don't have "miles" of spaces between them), I accidentally also removed the dash in front of "mc 0"... Sorry for wasting your time on reading the above post :( Nevertheless, there is another thing: the video looks really odd. Certain layers(?) seem off. Here's a screenshot from Megaman 6: Another one from Super Mario World on the SNES, because there seems to be the same thing there and in this shot is way more clear to see it:
Former player
Joined: 12/5/2007
Posts: 716
Finally figured out what was going wrong, at least for SNES encoding (haven't tried NES again): in unix/nesvideos-piece.cc the intro length and its overlapping part is determined. Of course I didn't have the files under the path hardcoded there, but after either deactivating the logo or providing the logo files, the video looks just great. In case I oversaw it somewhere on the page, I'm sorry for the spam. If it's not the case, a little comment in the encoding HOWTOs might be appropriate, I guess.
Editor, Active player (296)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Ah, the colour smearing. This is an annoying bug that appeared once without any clear reason. To fix it, change the module that calls NESVideoLoggingVideo and switch the state of the #if that decides whether to send I420 data to the codec directly instead of sending whatever the emulator produces. Sorry about it!
Former player
Joined: 12/5/2007
Posts: 716
That perfectly fixed the NES smears for me. Thanks a lot!