Created
March 4, 2017 11:52
-
-
Save crowjdh/fc8a048bc42706b79756d383dd6d1700 to your computer and use it in GitHub Desktop.
This file contains 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 characters
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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, Where's Process come from?