2013-02-11 186 views
3

我需要流式傳輸我的Mac桌面,讓其他人觀看我正在做的事情。我試過使用VLC(它不再適用於當前的穩定版本)。我試過fxmpeg,它不再適用於osx上的x11grab選項。你知道任何商業或免費的軟件,具有屏幕錄製和流媒體功能嗎?或者,也可以通過管道連接到ffmpeg或vlc?或者,也許你可以指點我學習如何構建一個捕捉屏幕的OSX非常基本的應用程序? 謝謝osx上的屏幕截圖

+0

您是否閱讀過[OSX上的C++捕獲屏幕圖像] [1]?很多鏈接,特別是最後一個。 [1]:http://stackoverflow.com/questions/1537587/capture-screen-image-in-c-on-osx – 2013-02-13 09:30:37

+0

我編程該C代碼來捕捉的Mac的畫面,並顯示出它在OpenGL窗口中通過函數glDrawPixels: opengl-capture.c http://pastebin.com/pMH2rDNH – 2013-07-06 10:08:50

回答

0

這是一個示例代碼捕獲屏幕並將其保存爲一個爲我工作的文件。

/** 將當前屏幕記錄到上述目標路徑。 **/

- (空)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]; 

}

您可以在http://developer.apple.com/library/mac/#qa/qa1740/_index.html

找到示例代碼請通過網址。這可以幫助您至少創建捕獲屏幕的基本應用程序。