Skip to content

Instantly share code, notes, and snippets.

@crowjdh
Created March 4, 2017 11:52
Show Gist options
  • Save crowjdh/fc8a048bc42706b79756d383dd6d1700 to your computer and use it in GitHub Desktop.
Save crowjdh/fc8a048bc42706b79756d383dd6d1700 to your computer and use it in GitHub Desktop.
func filterVideo(inputFilePath: String, outputFilePath: String,
filterPath: String, callback: @escaping (Bool) -> Void) -> (Process, DispatchWorkItem)? {
guard let launchPath = Bundle.main.path(forResource: "ffmpeg", ofType: "") else {
return nil
}
let process = Process()
let task = DispatchWorkItem {
process.launchPath = launchPath
process.arguments = [
"-y",
"-i", inputFilePath,
"-filter_script:v", filterPath,
outputFilePath
]
process.standardInput = FileHandle.nullDevice
process.launch()
process.terminationHandler = { process in
callback(process.terminationStatus == 0)
}
}
DispatchQueue.global(qos: .userInitiated).async(execute: task)
return (process, task)
}
@vansabean
Copy link

Hello, Where's Process come from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment