Suggestions on capturing video from opengl app?

Member
Posts: 52
Joined: 2007.06
Post: #1
Hey,

I was wondering if i could get some suggestions on creating a video of an opengl app that i have created over the years?

I know i can just dump the frame buffer pixels at a 60 hz dump rate and use idvd or imovie to play those files, but i assume there must be an easier way and possibly implemented already in a nice package or something, :-)

Any suggestions welcome,

Thanks!
Quote this message in a reply
Member
Posts: 283
Joined: 2006.05
Post: #2
Yeah, you have to get image data out of OpenGL and then compile it into a movie. The first isn't particularly fun, but there's sample code readily available. The second requires you to use the QuickTime API, which is no fun at all.

Luckily, I think the Inkubator project used someone's game base (can't remember whose) which had this functionality. You might want to check that out.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #3
If you're doing Cocoa, there is a movie recording class in GameBase that you should be able to drop right into your project. See GBMovieRecorder: http://idg-inkubator07.svn.sourceforge.n...ork/trunk/

[edit] maximile's on the ball already! BTW, the code I wrote there is based on TomorrowPlusX's stuff from his SimpleGameFramework.
Quote this message in a reply
Member
Posts: 52
Joined: 2007.06
Post: #4
Sweet, thanks fellas.

PS im using cocoa, but honestly im not doing anything with it. I needed it to get everything to compile when i switched everything over to the mac, lol. I guess im going to understand it a little better after this,
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #5
AnotherJake Wrote:If you're doing Cocoa, there is a movie recording class in GameBase that you should be able to drop right into your project. See GBMovieRecorder: http://idg-inkubator07.svn.sourceforge.n...ork/trunk/

[edit] maximile's on the ball already! BTW, the code I wrote there is based on TomorrowPlusX's stuff from his SimpleGameFramework.

IIRC, your rewrite of my capture code was better than my original stuff. I'm going to have to scope this out.
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #6
maximile Wrote:The second requires you to use the QuickTime API, which is no fun at all..

It's not toooo difficult to create a movie if you use the cocoa QTMovie's addImage:forDuration:withAttributes function. There are some caveats however. Don't be expecting to be able to change the output codec or any of those settings without delving into yucky quicktime code for example, and if you're targeting older systems there is a standing bug on (some?) 10.4.x systems which will render your movie over top of the menu in the top left of the screen without some GWorld hackery ( see this technote )

Personally I just use iShowU. Though frame rates can be difficult to keep up while recording on lower end systems, for presentation on the web it really doesn't matter.

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #7
reubert Wrote:...there is a standing bug on (some?) 10.4.x systems which will render your movie over top of the menu in the top left of the screen without some GWorld hackery ( see this technote )

I'm still seeing that bug on 10.5.x.

Probably I'm using QTKit incorrectly, but it's infuriating, since the use of deprecated GWorld code means I get a fair number of warnings in my build. I'm one of those sticklers who considers warnings to be errors.

I will have to look at the inkubator code...
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #8
TomorrowPlusX Wrote:I'm still seeing that bug on 10.5.x.

Interesting. Perhaps it is a PPC or GPU specific thing. It is definitely not good to be forced into using deprecated functions to achieve something so basic without graphical artifacts. I suppose we should be thankful that it's even possible to write frames to a movie in Cocoa, but it does seem well overdue for a fix.

We can only hope that a more feature complete Quicktime Cocoa API will be one of the Snow Leopard additions.

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #9
I figured out how to get around using any GWorld junk. Unfortunately, I completely forgot what I did differently. Doing a quick scan of it I can't quite tell, maybe I used SetMovieVisualContext instead? That would require QT 7 (I think).

[edit] Yes, that was it. I used SetMovieVisualContext([movie quickTimeMovie], nil); instead of NewGWorld and SetMovieGWorld.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #10
AnotherJake Wrote:I figured out how to get around using any GWorld junk. Unfortunately, I completely forgot what I did differently. Doing a quick scan of it I can't quite tell, maybe I used SetMovieVisualContext instead? That would require QT 7 (I think).

[edit] Yes, that was it. I used SetMovieVisualContext([movie quickTimeMovie], nil); instead of NewGWorld and SetMovieGWorld.

I was looking at the code earlier and saw that bit -- it just poked me in the eye. It looks encouraging, and I'll see if that fixes the issue with my code.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #11
As a followup, that line did in fact allow me to drop my GWorld code completely. Awesome!
Quote this message in a reply
Member
Posts: 283
Joined: 2006.05
Post: #12
I've tried to use GBMovieRecorder in my app, but I'm getting the following logged to the console every time I call recordFrameWithTimeStamp:

Code:
2008-08-22 14:32:54.620 Chipmunk Playground[8205:613] *** -[NSConditionLock unlockWithCondition:]: lock (<NSConditionLock: 0x1540b0> '(null)') unlocked when not locked
2008-08-22 14:32:54.621 Chipmunk Playground[8205:613] *** Break on _NSLockError() to debug.
The output movie is the right size and duration but completely black. I've tried disabling VBL sync, and I've tried slowing the frame rate right down so that it has time to record. Neither helped.

Can anyone think of anything I might be doing wrong? I'm a bit lost with threads, so I don't know where to start looking. I can post any code that might be relevant. Many thanks.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #13
That's weird. I wonder how the heck it gets into a condition where it unlocks an unlocked thread? You have to be calling beginRecordingSourceRect to get the file right? You *are* calling beginRecordingSourceRect first right?
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #14
I just noticed that it appears to be sending a lock message to null. That's weird. If you can send me a project which demonstrates this, I can get to the bottom of it a *lot* quicker. Send to anotherjake +AT+ mac.com if you can.
Quote this message in a reply
Member
Posts: 283
Joined: 2006.05
Post: #15
Yes, I called beginRecordingSourceRect. I've e-mailed you the project.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Transition from programmer to video game programmer &lt;book suggestions&gt; Achithyn 12 5,633 May 28, 2006 12:13 PM
Last Post: Achithyn
  Capturing Arrow Key Press robmcq 5 5,323 Oct 7, 2005 01:19 AM
Last Post: codemattic
  Capturing Kestrokes honkFactory 2 3,062 Jan 27, 2003 04:30 PM
Last Post: OneSadCookie