Screen capture on osx

I need to transfer my Mac's desktop and have other people see what I'm doing. I've tried using VLC (which no longer works in the current stable release). I tried ffmpeg which no longer works with the x11grab option in osx. Do you know of any software, commercial or free, with screen recording and streaming functionality? Or, alternatively, something that can be piped to ffmpeg or vlc? Or maybe you can point me somewhere to learn how to create a very simple osx app that captures the screen? Thanks to

+3


source to share


1 answer


This is a sample code to capture a screen and save it as a file that worked for me.

/ ** Write the current screen to the specified destination path. ** /

- (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 sample code http://developer.apple.com/library/mac/#qa/qa1740/_index.html

Please go to the url. This can help you when creating a basic app that captures your screen.

0


source







All Articles