.kkapture: sufficiently advanced technology.
what is it?
.kkapture is a small tool that produces video+audio captures of fullscreen apps (usually demos).
unlike fraps, it does not run in realtime; instead, it makes the demos run at a given, fixed
framerate you can specify beforehand. in other words, .kkapture can make 60fps video captures of any
demo your computer can run, even if each frame takes several seconds to render.
why would someone want this?
for windows demos, it is usually not much work to add a video writer to your program. however, that
has to be done by the authors; the nice part about .kkapture is that it is sufficiently general to work
with a wide variety of demos, automatically. if you do demos yourself and .kkapture is able to handle your
demo without problems, well, you've just saved yourself the work of coding a video writer yourself.
the main application area is when you want to make several quality video captures of different demos
in a short period of time, without having to contact each of the coders. production of demo dvds or pre-cut
demoshows would be a prime example.
how did it come to be?
well, rather simple story; i was rather annoyed by the generally so-so video quality of the
2004 scene.org awards, mostly caused by repeated frame-rate changes (first fraps which captures at whatever
rate the demo runs, then video encoding, then playback on a computer with whatever refreshrate it's using,
then conversion by the beamer). the fixed framerate capturing should be able to get rid of most of these
problems, by simply avoiding the necessity of framerate conversions altogether.
how does it work?
if you want the gory details, just look at the provided source code. here's a short executive summary:
.kkapture works by hooking certain graphics api functions to capture each frame just as it is presented
on screen. all popular ways of getting time into the program are wrapped aswell - timeGetTime,
QueryPerformanceCounter, you name it. this is necessary so .kkapture can make the program think it runs
at a fixed framerate (whatever you specified). the most tricky part is audio, because it doubles as
both capture signal and sync source. .kkapture provides a custom (and very dumb) directsound implementation
that emulates an actual soundcard again updating with your exact specified framerate. waveout support is
present too, though it is untested at the moment, so beware.
how to use?
well, download it, start kkapture.exe, specify demo/video file name and framerate, hit "kkapture!",
select your codec of choice and that should be it :). however, you have to execute the demos in fullscreen
mode; i currently use mode switches to determine the size of the image to capture. this is not a technical
necessity, but it was the simplest way to get that information at the time, and .kkapture is still in a
very early stage (as the version number might suggest ;).
about "skip silence" and "make sleeps last one frame": both these options fix problems for certain
demos/intros and cause problems with others. the default settings are what works best most of the time, but
if you're experiencing problems, try setting these switches to other settings.
where can i get it?
latest stable release
known issues
- lots of incompatibilites with demos that don't make sense to list here.
- the source code could use some cleanup.
change log
version 0.07:
- "frame timed out" now mentions which frame was skipped (if you want to check whether the video is fine or if it causes problems)
- if kkapture is being debugged, main.cpp now gives you time to attach the debugger to the target demo aswell.
(this is the deluxe version of a hack i've been using for ages - thought it might be useful for others trying to debug, too :)
- fixed some bugs in the cleanup code that may have caused crashes after recording was complete.
- waveOutGetPosition now even accepts wrong size specifications for MMTIME struct as long as they're big enough (helps candystall).
- ddraw code temp surface handling should now be more stable (helps with moral hard candy)
- seeding of all timers now synchronized. helps with demos that mix timing values returned from independent sources (not a good idea!!!).
in any case, fixes problems with ante dominum.
- "power down after completion" switch (by popular request).
version 0.06b:
- now default to vfw video encoder on new installations.
- "fairlight hack" switch now explicit due to request - turn it on for track one and possibly other flt demos, otherwise leave it off.
(was implicitly on in all versions from 0.05 upwards)
- more new startup instrumentation fixes (yaay!).
version 0.06:
- magic exit key (ctrl+break) improved: now uses lowlevel hook, should always work now.
- d3d8 capture fixes: r08028, nature v2.0 work now.
- vfw .avi writer can now also handle format changes while the demo is running.
- should now work with demos that use FMODEx: at least first offence works fine now.
- now automatically advances time if frames take too long.
fixes a LOT of demos that do busy waits somewhere, including:
- frameskool by equinox
- mupe by playpsyco
- abstinens by keyboards
- noumenon by andromeda
and probably a lot of other demos too.
how to use: check "Enable automatic frameskip on timeout".
the two timeout values define how much time the application has to render
the first/subsequent frames; if it takes longer, kkapture will skip a
frame and write a log message. lower timeouts mean faster kkapturing for
apps that explicitly perform waits every frame, but the lower you set those
values, the higher the risk that kkapture will drop a frame just because
rendering took a tad longer than expected. so be careful!
version 0.05b:
- IDirectSoundBuffer::SetFrequency handling fixed (affects onwards, 2^5 by traction)
- debug force-windowed code for d3d9 removed :)
version 0.05:
- small bugfix in dshow video encoder (thanks malc)
- "new startup instrumentation" button now actually does something :)
- startup instrumentation code now less picky about executable files
- startup instrumentation now works when first instr. is call/jmp (helps with several demos)
- added dc/rendering context tracking for opengl (fixes problem with animal attraction)
- synchronization policy changed in dsound code (fixes problems with mega hilter expansion pack, maybe some threading issues too?)
- old fallback gdi capture code removed (not required anymore and it never worked properly anyway)
version 0.04:
- switched to visual c++ 2005 express edition
- "new startup interception" that works on 64bit host machines (always on on 64bit, default off on 32bit)
- kkapture is now under the artistic license v2.0beta5
- small waveout code fix by manx included (thanks)
- automatic segmenting code for avi-vfw encoder by bartman included (thanks to you too :)
- automatically disables VSync during recording for most supported APIs (improves capturing speed somewhat)
- basic SetTimer support (i'm not particularly happy with it)
- improved resolution determination for opengl demos
- magic exit key: press ctrl+break to safely abort a capture.
- writes (approximate) capturing frame rate on exit
- small fix in doneTiming() to make sure no waits are currently active when timing is deinitialized
- improvements in d3d8/9 reference handling code
- support for demos that initialize/deinitialize the graphics API several times
version 0.04alpha:
- some performance improvements for directdraw capturing
- several bugfixes
- new directshow-based avi writer, currently the only one available (0.04 final will have both the old and new avi writer)
- automatic audio resampling (required for dshow, currently converts everything to 16bit 44.1kHz stereo)
- new timing code (not particularly well tested yet!)
version 0.03:
- waveout capturing finally works (now that was one stupid bug)
- directdraw/old d3d support (both software and hardware)
- kkapture now sets the executables' directory as current working dir before starting
- "skip silence" option added (required for e.g. fr-08); currently only works for directsound
- "make sleeps last one frame" option added and enabled by default (fixes sound sync for some demos,
causes problems with others - if you're experiencing problems with a demo, try the other setting)
- the .bmp/.wav writer now compensates for frames at the beginning without sound
- capture audio/capture video flags
version 0.02:
- direct xvid/divx encoding works now.
- windowed capture support for both opengl and d3d - beware, some demos do not use correct window sizes in
windowed mode, so you get e.g. a 630x472 capture for a 640x480 demo - most video codecs don't like sizes that
aren't multiples of 4.
- opengl capturing bugfix - on swapbuffers(), frames were accidentially advanced twice.
- some QueryPerformanceCounter-related fixes.
- vastly improved Direct3D9 capture speed.
- Direct3D8 support (co-written by kb/farbrausch).
- .bmp/.wav output added (uncompressed highres captures easily hit the avifile 4gb limit).
- lots of tiny fixes here and there.
version 0.01:
- initial release; still missing d3d8, ddraw support, waveout completely untested.
old versions
credits
refer to the "CONTRIBUTORS.txt" in the recent distributions.
contact
drop me a mail: ryg(a)theprodukkt,com