I need to stream the desktop of my Mac and make possible for other people watch what I am doing. I've tried using VLC (which no longer works in the current stable release). I've tried ffmpeg which no longer works with x11grab option on osx. Do you know any software either commercial or free that features screen recording and streaming? Or alternatively something that can be piped to ffmpeg or vlc? Or maybe can you point me somewhere to study how to build a very basic app for osx that captures the screen? Thanks
Asked
Active
Viewed 2,300 times
3
-
Did you read this [Capture Screen Image in C++ on OSX][1]? Lots of links, especially the last one. [1]: http://stackoverflow.com/questions/1537587/capture-screen-image-in-c-on-osx – Mike Versteeg Feb 13 '13 at 09:30
-
I programmed this C code to capture the screen of Macs and to show it in an OpenGL window through the function glDrawPixels: opengl-capture.c http://pastebin.com/pMH2rDNH – Juan Carlos Kuri Pinto Jul 06 '13 at 10:08
1 Answers
0
This is a sample code for capturing the screen and saving it as a file which worked for me.
/**
Record the current screen to the destination path mentioned.
**/
-(void)screenRecording:(NSURL *)destPath {
//Create capture session
mSession = [[AVCaptureSession alloc] init];
//Set session preset
//mSession.sessionPreset = AVCaptureSessionPresetMedium;
mSession.sessionPreset = AVCaptureSessionPreset1280x720;
//Specify display to be captured
CGDirectDisplayID displayId = kCGDirectMainDisplay;
//Create AVCaptureScreenInput with the display id
AVCaptureScreenInput *input = [[AVCaptureScreenInput alloc] initWithDisplayID:displayId];
if(!input) {
//if input is null
return;
}
//if input is not null and can be added to the session
if([mSession canAddInput:input]) {
//Add capture screen input to the session
[mSession addInput:input];
}
//Create AVCaptureMovieFileOutput
mMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
mMovieFileOutput.delegate = self;
if([mSession canAddOutput:mMovieFileOutput]) {
//If movie file output can be added to session, then add it the session
[mSession addOutput:mMovieFileOutput];
}
//Start running the session
[mSession startRunning];
//Check whether the movie file exists already
if([[NSFileManager defaultManager] fileExistsAtPath:[destPath path]]) {
NSError *err;
//If the movie file exists already, then delete it
if(![[NSFileManager defaultManager] removeItemAtPath:[destPath path] error:&err]) {
NSLog(@"Error deleting existing movie file %@", [err localizedDescription]);
}
}
//Start recording to destination path using the AVCaptureMovieFileOutput
[mMovieFileOutput startRecordingToOutputFileURL:destPath recordingDelegate:self];
}
You can find the sample code at http://developer.apple.com/library/mac/#qa/qa1740/_index.html
Please go through the url. This may help you atleast create basic application that captures your screen.