.kkapture: sufficiently advanced technology.
.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 general enough to work
with a wide variety of demos, automatically. If you write 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 is 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 a different refresh rate). 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
presen too, and in recent versions, .kkapture also intercepts some popular sound systems directly to make
sure the correct time is reported back to the application.
How do I use it?
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 :). Rarefluid
has written an article that explains some of the finer points if you want to create high-quality video captures.
There's also some checkboxes that turn on certain workarounds. The defaults usually work best, but if you're
dealing with a picky demo, try playing around with the flags a bit, it might help.
Where can I get it?
Latest stable release:
- added "fake additional screen resolution" option (thanks KeyJ)
- switched from (long defunct) detours 1.5 to free mhook-2.2 (http://codefromthe70s.org/mhook22.aspx).
- redid startup interception yet again: now using simple DLL injection via CreateRemoteThread. should work fine with .NET executables and be less flaky in general.
- sound: lock entire directsound buffer when dwBytes=0 (fix for "mother mother, my ears bleed")
- d3d11 support
- "skip frames on frequent timer checks" can now be turned off; threshold set to a substantially higher value.
- "virtual framebuffer" mode for old, badly written ddraw apps (e.g. "fall equals winter"). won't work with hw accelerated blits
and clears! use as a last resort.
- major bump in version number! :)
- timing: fixed a regression from version 0.07 (should work a lot better on vista and windows 7 now)
- sound/timing: automatically advance frame after some time when app asks for the current time a certain number of times (helps with several quite intros)
- sound: force fmodex to use dsound on vista/windows 7 (i won't write a windows audio session implementation if i don't have to)
- sound: some tweaks in waveOut support. now works just fine with the MS GS synthesizer.
- sound: make sure to return 0 as estimated latency for demos that use BASS. fixes asm 2009 invitation by andromeda.
- video: can now capture programs that use GDI for output as well. not particularly well-tested. original code by iq.
- "deep capture". can now kkapture demos that have a seperate launcher directly. tested on borg, etch-a-sketch. logfiles are now named
differently since there may be several! behavior if more than one program in the chain starts rendering is undefined (i.e. it won't work).
- new startup instrumentation: yet another new approach to entry point determination (to work with address space layout randomization)
- "attempt clean exit" key (right ctrl; has good chances of producing a usable .AVI, unlike ctrl-break)
- audio: automatically reduce WAVEFORMATEXTENSIBLE to WAVEFORMATEX if possible (for compatibility)
- audio: can now mix both stereo->mono and mono->stereo if required
- audio: WAVE_FORMAT_IEEE_FLOAT support (should help a lot with 4k intros using 4klang)
- waveOutGetTime fix (apparently, TIME_MS is *broken* and returns offsets in bytes too. ah well. fixes kindercrasher/rgba and probably some others too)
- "frame rate" edit control now supports arbitrary positive decimal ("12.3456") and fractional ("60000/1001") framerates
- "BASS/FMOD interception" added. BASS interception removes the need for the fairlight hack, FMOD interception fixes FMODs
broken timing code to make demos run at a higher framerate than 43fps.
- separate encoder thread option (makes everything much faster on multicore systems, but the code isn't very well tested)
- ddraw capture fix: now also grad frames on primary buffer unlock (fixes voidspace/woorlic, fall equals winter/replay)
- post a dummy WM_NULL message to foreground window every frame (fix for some old hjb intros)
- new startup interception fix: treat calls in startup code differently ("dead cells" now works)
- d3d10 support (only tried it on texas though, so it's not particularly well-tested).
- "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).
- 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!).
- 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:
and probably a lot of other demos too.
- frameskool by equinox
- mupe by playpsyco
- abstinens by keyboards
- noumenon by andromeda
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!
- IDirectSoundBuffer::SetFrequency handling fixed (affects onwards, 2^5 by traction)
- debug force-windowed code for d3d9 removed :)
- 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)
- 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
- 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!)
- 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
- 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.
- initial release; still missing d3d8, ddraw support, waveout completely untested.
Drop me a mail: ryg(a)theprodukkt,com