0

I know:

# ffmpeg -f avcapture -video_device_index 0 -i "" ~/Desktop/capture.mpeg

This will generate a video file. But how to do this programmatically in Xcode? I am trying to build a screen recorder which supports FFmpeg in macOS.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
sol
  • 13
  • 2
  • Duplicate: https://stackoverflow.com/questions/22789827/building-ffmpeg-ios-libraries-for-armv7-armv7s-arm64-i386-and-universal – El Tomato Nov 29 '17 at 04:35
  • I was asking for macosx not ios.. and i was asking for programmatic approach steps etc to be followed. – sol Nov 30 '17 at 02:30

1 Answers1

1

You can use NSTask to launch other tasks, for example:

NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/local/bin/ffmpeg"]; // Path to ffmpeg, if included in the resources [[NSBundle mainBundle] pathForResource:@"ffmpeg" ofType:""]
[task setArguments:@[@"-f", @"avcapture", @"-video_device_index", @"0", @"-i", @"\"", @"~/Desktop/capture.mpeg"]];    
[task launch];     
[task waitUntilExit];

int status = [task terminationStatus];
if (status == 0)
{
     NSLog(@"Task succeeded.");
}
else
{
    NSLog(@"Task failed.");
}
Maarten Foukhar
  • 349
  • 1
  • 11
  • thanks. can we set fps and other presets to adjust quality? will I be able to create WebM format file? – sol Dec 03 '17 at 14:59
  • 1
    All options supported by ffmpeg should work, WebM and frames per second are options I use in my application that uses ffmpeg (Media Converter -> http://media-converter.sourceforge.net). – Maarten Foukhar Dec 04 '17 at 09:27