Skip to content

Instantly share code, notes, and snippets.

@cihadturhan
Created March 13, 2021 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cihadturhan/26f2f82e3fbc7336cb4683fd61050c86 to your computer and use it in GitHub Desktop.
Save cihadturhan/26f2f82e3fbc7336cb4683fd61050c86 to your computer and use it in GitHub Desktop.
Execute ffmpeg from unity on MacOS
// 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