Mac OS screen as video source - objective-c

I'm want to create application for OSX where I can record video from webcam and from screen(at the same time or in succession).
In Windows I can use DirectShow and ScreenCapture filter as video source, but in Mac OS we have no DirectShow and filters.
Is it possible to create something like ScreenCapture filter in windows for Mac OS?
Maybe it's must be some video kext or something else.
Can anybody help me with this question?
Thank you.

Apple have an example of recording the screen. Technical Q&A QA1740
How to capture screen activity to a movie file using AV Foundation on
Mac OS X Lion
Q: How do I capture screen activity to a Quicktime movie on Mac OS X
Lion?
I am on mountain lion. With a little tweaking the example works.
EDIT 1* here is a second example from Apple AVScreenShack. Sample Project
Note:I could not get the AVCaptureSessionPresetHigh to work for high quality in either example. Apart from if I set the input's cropRect width & height to anything below 700x700 in the first example.
But the AVCaptureSessionPresetPhoto worked fine and captured the whole screen in good quality.
Edit 2*
Here is Apples sample to record using a device such as an iMac Camera. The sample Project works from the get go.
AVRecorder

have look at here. Get many images and make a video from that images.

Open the QuickTimePlayer (at home in the Applications folder) click: File --> try: New Screen Recording (and play with the other two menu items).
I think it is close to what you want to do.
A new panel will open; play with the triangle at the right side:

Related

Use OS X to take pictures with camera connected over usb

I'm currently creating an OS X application that makes use of a
camera (Nikon D700) to take pictures. Is there any way to create an application that takes pictures?
For instance: I click on a button in my program, and it takes a picture with the camera, and sends it directly back to the program.
The programming language does not really matter.
Any help or related posts are welcome.
Thanks!
Reense

Adobe Air laggy on Dell Inspiron Touch 1

OK, this might be a very specific question, but I am seriously stuck.
I have an Adobe Air desktop app which runs fullscreen on a Dell Inspiron Touch PC (OS is Win8). The interaction involves some dragging with the finger/mouse.
Edit: I use Air 3.8
Here's my problem: when operated with the mouse, everything works fine and smooth, on this computer and on every other PC I tested it on. But with touch input everything becomes obviously laggy.
When operated by touch, the OS shows a dot which indicates the current position of the recognized finger. When the finger is moved around, this OS output is significantly more responsive than the Air app, where dragging takes longer and lags. So I assume that the problem lies in delivering the touch events to the app.
What I have tried:
setting different values for MultiTouch.inputMode, assuming that
MultiTouchInputMode.NONE would be the most performant
installing a new driver for touch input
setting the mouse speed of the OS to "high"
setting the touch area size of the OS to "small"
Nothing did have an impact, and I am out of guesses…
Does someone have an idea or even experience with this stuff?
Thanks!
Because I had very little time and had to find a solution very quickly (it was a kiosk app for an event), I chose this alternative which worked perfectly: I made a flash file that is shown in the browser in fullscreen. No lag, no performance issues at all. I still don't know what caused this behavior though. No time…

How do I stop Cocos2D from requiring standard definition resources (SD images)?

I am developing an iPhone game with Cocos2d-iphone.
I want my game to only be available to the iPhone 4 AND iPad. Retina enabled for iPhone 4. I don't want the game to run on older devices.
Cocos2d will always ask me for -hd and non-hd files. If I don't provide the SD files, I get errors. I don't want that: is there a way to disable Cocos2d from trying to retrieve SD files, and only get -hd suffixed files by default?
Oh, and when the game is run by an iPad, the graphics will be the -hd ones as well. So the point is, I only want to have -hd files in my project.
What are the proper steps to edit Cocos2d's source for such?
If you are using cocos2d version >= 2.0, then you can change the value of a global variable found in CCFileUtils.h:
static NSString *__suffixiPad =#"-hd";
(Its default value is #"-ipad".)
If you are using cocos2d version < 2.0, then you can find here a category that I wrote to be able to transparently use -hd images created for the iPhone 4 on the iPad 1/2.
Actually, it does more than that, but if you add it to your project, then "-hd" images will be "automagically" used on the iPad 1/2 instead of their SD versions (which you could also not include in your project).
Let me know if you have any issues integrating this code.
If I would have been at your place.. I would have played with a trick.. Don't down vote the answer if you don't like.. But Its just a thing in my mind.
Use -hd images in the code directly.. iPhone 4 will handle it easily.. Older iPhones will show it much larger and it doesn't matter as you are not supporting them...
So instead of using Background.png , directly use Background-hd.png as it will work fine for iPhone 4.. Instead of wasting time on all these SD stuff.. I will directly use my -hd images for my work...
I can not say about new iPad.. But old iPad can easily use -hd images in code as you want.. For iPad I have directly used in my code earlier..
Hope this helps.. :)
This tutorial might help.
If you only provide -hd assets, you should only get errors regarding missing SD assets when running on iPad. The iPad doesn't have a Retina display, but it certainly is high resolution enough to be treated like one.
Since cocos2d passes all filename requests through the fullPathFromRelativePath function in CCFileUtils it may be enough to modify this function to treat the iPad like an HD device and force it to load -hd assets on iPad.
the 1st idea i can think of is to use #2x suffix for images (UIKit style) and you wont need to enable retina display in app.The problem is that on the ipad you'll have to write your own method to remove #2x suffix
the 2nd idea was to make a SD image..but only 1x1 pixels... it takes virtually no space at all ( 119 bytes with white pixel). Should work on ipad as-is
3rd idea:don't enable (or enable..doesn't make any difference) retina display but have the HD images as SD images.I've tested this on cocos2d v1.0.1 and it seems to work.Also..it should work on ipad
4th idea forcefully enable retina display in ccConfig.h (so that director won't ask you for the SD images on ipad) .I'm not sure about this one because there are quite a few tests that check for resolution, device and if it's retina and you'd have to edit all of them
these are just ideas off the top of my head..they may be wrong..but they're just ideas

Directly Record Screen on Mac

OK so I want to record the screen of a Mac directly to a .mov or .m4v. I've taken a look at Son of Grab from Apple, but I would prefer not to deal with screenshots and individual images and just work with video.
I thought there should be something in QTKit but I can't find it. I know this can be done in OpenGL, but 1) I don't know how and 2) I'd like to avoid that if possible.
Just to elaborate, I am recording from iSight using QTCaptureDeviceInput and (obviously a QTDevice) because I need to solution to work on Snow Leopard.
It seems like there should be a way to just target the screen as the input device for QTMediaTypeVideo.
Any help would be greatly appreciated.
You can use AVFoundation to do screen recording on the Mac. It's only available on 10.7 though.
You can use CGDisplayCreateImage/CGDisplayCreateImageFromRect APIs (10.6+) to obtain still images of screen and then making a movie out of them.
I'm not sure how good will be the performance though.
I have found that when faced with the question, will it be fast enough or not, just give it a try. Do a quick test by gabbing frame after frame say 1000 times and time it. CGDisplayCreateImageFromRect is not that hard to call at all. I have called it for single screen shots of the whole screen when the mouse was clicked, and it hardly slowed my mac down (only a basic dual core machine).
Apple has two samples showing the main two ways this can be done: :-
ScreenSnapshot
SonOfGrab
It would be easy to modify these to do it say 1000 times in a loop!

how to change spaces like dvd player?

I want to program an application that changes spaces the way DVD Player does on OS X (screenshot of the transition below, but it may not be helpful because I cannot get my timing right). How can I make my application open a window, and move into a different space the way DVD Player does?
That's a new feature in OS X Lion. It's called Fullscreen apps. You'll want to look at the documentation for how to get your app ready for Fullscreen:
http://developer.apple.com/library/mac/#documentation/General/Conceptual/MOSXAppProgrammingGuide/FullScreenApp/FullScreenApp.html