Introducting UnityCapture Plugin (Pro and OSX only)

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).

Excellent work! Will you be making this a commercial product eventually?

Very cool, Adrian!

Thanks! Not sure what to do with it yet, it was more of a personal test to see if I could get this to work. I’m thinking about releasing it as donationware.

Look’s nice

So cool,take a look… 8)

Just put out beta 2.

Fixes the annoying incompatibility with Final Cut and adds an option to set the capture resolution in the GUI (which will simply change the player’s resolution at the start of capture and restores it at the end).

If you use UnityCapture, please drop me a line!

Would it be terribly hard to make a Windows version? :smile:

Yes. :?

It uses a lot of OSX APIs and I was able to adapt the compression code from one of Apple’s example applications. Porting it to Windows would require rewriting almost all of it.

The source is open so if anyone wants to make something similar for Windows they can take it as a reference.

Hmm,
Does anyone else think that this should really be an integral feature of both Unity Pro and Indie?

My thinking on this is that to be commercially successful we need people to download the unity plugin and also need to pitch to people who don’t have the plugin installed.

One of the best ways of persuading people who don’t have the plugin is to show them a high quality video clip.

At the moment I’ve seen a variety of clever approaches to this but none of them are that straightforward. Presumably this would all work much better if a video capture facility was built into Unity because you’d never miss frames and 100,000 users would easily be able to create marketing videos for their products.

If anyone else thinks this should be part of Unity let me know and I’ll add it as a wish

It’s not quite working for me. I’m building an OS X Intel standalone in Unity 2.6.1 and OS X 10.6.2. When I Ctrl-C the capture window appears, capture starts and then the player freezes.

For fun I converted the Boo script to C#. I was kinda hoping it would work in the Editor in Unity iPhone but alas…

The above problem happens with either your original Boo and my C#.

267765–9626–$unitycapture2_128.cs (4.5 KB)

Thanks so much for this script - it’s really really awesome!
Screenium did a great job for me capturing at iPhone-resolution, but it seems my iMac doesn’t have enough power to capture fluid 720p. This script solves the problem top notch!

Hi,

thats a great one…but it´s not working under 10.6, is that correct?

Has anyone tried it under 10.6?

Thanks
Marc

Excellent job, Adrian, thank you so much for sharing this ! :smile:

Here’s an example movie I just captured from the scene I’m working on, with the camera controlled in realtime : http://tiviboo.com/unity/uctest.mov

NB :

  • it was made under OSX 10.6.2
  • due to the low compression I chose, it could run jaggy if played before the whole movie is loaded.

Is this Plug compatible with OS X 10.6.4 Unity 3 ?
Thx :slight_smile:

If someone did a windows version it’d be nice to unify it into this so end users could use it regardless of OS

@Yann: wow that terrain looks sweet! how did you make it so realistic?

@Adrian: nice tool! i’m on basic. :frowning: but still cool for the pro users!

@Yann: That terrain is awesome, how did you do it?

@3dDude and livin41 : this is a low-geometry terrain (512) with a hi-res (4096) colored lightmap in the lightmap channel (baked from a hi-geometry version of the same terrain) and a slightly modified standard terrain texture for closeups… it was a test for of a long-term project called… “The long, long run”, precisely :wink:

@diese440 : yes, I have used Adrian’s tool successfully a few days ago with such a setup !

ok thanks! how did you make the hightmap? did you render it with some other program?

thanks