Introduction
Recently I wanted to record some gameplay footage and started up IShowU. The last time I gave in to let it scale down the capture since I couldn’t get a smooth result otherwise. This time I really wanted to capture 720p and while it worked reasonably well with my new setup, there were still some dropped frames.
I could have given in at that point and concede to capture at a lower resolution or live with the dropped frames. But I think HD and a smooth capture is important for promotional game footage and so I decided to find a solution.
There’s Time.captureFramerate in Unity which enables you to render frames at a fixed game-time interval which will get you a wonderful smooth video. But you’ll have to get the frames out of Unity somehow and the only option Unity gives you is to create a series of PNGs (there’s a script just to do that).
But doing so is really slow. PNG encoding is not very efficient for movies and Unity does all the processing on a single thread. To capture 720p30 this way, you’re lucky to get 1fps. That’s fine for cutscenes but a bit stressing for gameplay footage.
So I did the obvious: Create a better solution. Luckily, Unity doesn’t make it too hard for you.
About
So, after a weekend of coding, I can present you UnityCapture: The ideal solution to capture Unity footage (if you’ve got Pro and OSX, which you hopefully do).
UnityCapture is a plugin that uses OpenGL to read the rendered frame into memory and then uses QuickTime to compress it.
It does so on different threads and is pretty quick. I was able to capture to MJPEG 720p30 at full-speed, 720p60 at 30fps and 1280p60 at 20fps.
Oh, and since it’s cumbersome to handle filenames and compression settings through Unity, there’s a nice GUI:
Download
Note that UnityCapture is still beta and I have done only limited testing. Reports about issues/performance are welcome.
The current version is 1.0beta2.
http://unityhelpers.googlecode.com/files/UnityCapture%201.0beta2.zip
Unity Capture requires OSX 10.5 and Unity Pro!
Changes
1.0 beta2:
- Added option to set capture resolution with GUI (which change the player’s resolution).
- Fixed captures not being compatible with Final Cut.
Install - Copy the UnityCapture.bundle together with the UnityCapture.boo script into your Assets/Plugins folder (just create one if it there is none).
- Add the UnityCapture script to every scene you want to capture.
- Make a new build
Usage - I recommend to make your captures in a Player. If you really want to try it in the editor, maximize the game view or you won’t get what you want.
- Hit ctrl-c to open the capture window. Click on the triangle to expand all settings, stats and options.
- You can start/stop the capture in the GUI or hit ctrl-s inside the game.
- You can change scenes as long as the scene you change into also has the UnityCapture script. You shouldn’t change the size (e.g. switch into fullscreen) while running a capture.
- For best results, use a fast codec. The default is Motion JPEG but I recommend the Apple Intermediate Codec if you have FinalCut installed.
Known Issues - ??? (report them, I haven’t done extensive testing).