Unable to call ffmpeg from OSX app

Asked 2 years ago, Updated 2 years ago, 137 views

We are developing at Unity.
I wanted to install ffmpeg in the OSX app, so I installed ffmpeg on the macPC and
We have created the following code.

private IEnumerator ffmpeg (string a_path)
{
 input="\"+a_path+"\";
 output="\"+UnityEngine.Application.persistentDataPath+"/work/"+"hoge.mp4"+"\";

 string ffmpegExePath="ffmpeg";
 Process process = new Process();


 US>string option="-i";
 option+=""+input;
 option+="-vf";
 option+="scale=480:270";
 option+="-an";
 option+="-preset everyfast";
 option+="-tune film";
 option+="-crf23";
 option+="-threads2";
 option+=""+output;

 string l_cmd =ffmpegExePath+option;
 
 process.StartInfo.FileName="/bin/bash";
 process.StartInfo.Arguments="-c\"+l_cmd+"\";
 process.StartInfo.CreateNoWindow=true;
 process.StartInfo.UseShellExecute=false;
 process.StartInfo.RedirectStandardError=true;
 process.StartInfo.RedirectStandardOutput=true;
 
 process.EnableRaisingEvents=true;
 process.ErrorDataReceived+=newDataReceivedEventHandler(ProcessErrorDataReceived);
 process.OutputDataReceived+=newDataReceivedEventHandler(ProcessOutputDataReceived);
 process.Exited + = new EventHandler (ProcessExited);
 
 process.Start();
 process.BeginOutputReadLine();
 process.BeginErrorReadLine();
}

However,

/bin/bash:ffmpeg-i'/Users/hoge/dev/unity/Video Test 5% u20106 Compressed.mp4'-vf scale=480:270-an-preset veryfast-tunefilm-crf23-threads2'/Users/hoge/Library/Application Support/HOGEOgure/HOwork: Application

You will receive an error.
"When I copied the command from ""ffmpeg-i"" and checked it at the terminal, I confirmed that ffmpeg will start."

When I changed l_cmd to "ffmpeg-version" and tried to see if I could check the version, it replied "/bin/bash:ffmpeg:command not found" and
You may not recognize ffmpeg as a command.

How can I call ffmpeg here?
We are currently checking on the Unity emulator.

The Unity version uses 2020.3.1 f1.

Thank you for your cooperation.

Additional
The installed ffmpeg can now be called, so I tried putting the downloaded binary file in the StreamingAssets folder, but the permission denied came out and I couldn't start it.
Do you know what this is?

string ffmpegExePath=Application.streamingAssetsPath+"/KirinUtil/ffmpeg_mac/ffmpeg";

tried to change to .
Thank you for your cooperation.

macos unity2d ffmpeg

2022-09-30 20:17

1 Answers

string ffmpegExePath="ffmpeg";

Why don't you rewrite the ffmpeg in to a full path that you can get in which and so on?
(I don't know how it was installed, for example
/usr/local/bin/ffmpeg
and so on.


2022-09-30 20:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.