Created
March 4, 2017 11:52
-
-
Save crowjdh/fc8a048bc42706b79756d383dd6d1700 to your computer and use it in GitHub Desktop.
Revisions
-
Chris Jeong created this gist
Mar 4, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ 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) }