On Feb 23, 2011, at 4:40 PM, Kyle Sluder wrote:

> On Wed, Feb 23, 2011 at 2:17 PM, eveningnick eveningnick
> <eveningn...@gmail.com> wrote:
>> i am trying to write a video grabber, CGWindow API seems pretty convenient
>> (because it allows to select which window to "grab"), but i am worried about
>> the speed, because i need to record the grabbed frames to the video file.
> 
> http://developer.apple.com/library/mac/#samplecode/OpenGLScreenCapture/Introduction/Intro.html%23//apple_ref/doc/uid/DTS10004445-Intro-DontLinkElementID_2

Actually, I don't think that's an improvement over the CGWindow API that 
eveningnick was already using (CGWindowListCreateImage, I assume).  In general, 
if a high-level (more abstract) API achieves the desired result, it will be at 
least as efficient as the low-level API -- because, if the low-level approach 
is faster, the high-level API would just use it.

Snow Leopard also introduced CGDisplayCreateImage[ForRect]().  It's probably of 
similar speed, although maybe faster because there's no attempt to examine the 
window list or window positions, etc.

With regard to speed, that's almost certainly more a function of the hardware 
(GPU, CPU, buses between the two, display resolution, etc.) than the function 
used.  Of course, the size of the grabbed area will also be important.

My understanding is that a CGImage can wrap a texture (or whatever) in VRAM.  
So, creating the image itself may happen entirely within the GPU and be 
stunningly fast.  However, if you then wish to write the image to disk or 
process its bits in the CPU, it will have to be copied from VRAM to RAM, which 
is potentially slow.  But there's no way to avoid that slowness -- you need to 
get the image from VRAM to RAM at some point to perform those operations, and 
CGImage is probably as good a way as any to do that minimally and most 
efficiently.

Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to