Created
March 13, 2021 23:05
-
-
Save cihadturhan/26f2f82e3fbc7336cb4683fd61050c86 to your computer and use it in GitHub Desktop.
Execute ffmpeg from unity on MacOS
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 characters
// Make sure you have ffmpeg installed at /usr/local/bin/ffmpeg | |
static void ExecuteProcessTerminal(string inputFileDir) | |
{ | |
try | |
{ | |
var outputFileName = Regex.Replace(inputFileDir, @"\.(mp4|mov|MP4|MOV)", ".wav", RegexOptions.IgnoreCase); | |
ProcessStartInfo startInfo = new ProcessStartInfo() | |
{ | |
FileName = "/usr/local/bin/ffmpeg", | |
Arguments = $"-y -i {inputFileDir} -async 1 -ac 2 -ar 44100 {outputFileName}", | |
UseShellExecute = false, | |
RedirectStandardError = true, | |
RedirectStandardInput = true, | |
RedirectStandardOutput = true, | |
CreateNoWindow = true, | |
}; | |
Process myProcess = new Process | |
{ | |
StartInfo = startInfo | |
}; | |
myProcess.Start(); | |
string output = myProcess.StandardOutput.ReadToEnd(); | |
Debug.Log(output); | |
myProcess.WaitForExit(); | |
myProcess.Close(); | |
// callback("file://" + outputFileName, "wav", 1); | |
} | |
catch (Exception e) | |
{ | |
Debug.LogError(e); | |
// callback("", "wav", 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment