Xamarin Mac FFmpeg launch path not accessible
I have a Xamarin Forms project with Mac support and I am trying to implement FFmpeg, so I have downloaded the Static build from its official page and added it as in the resources folder of the Mac project with the build action in Content, then I have created a service that will basically remove the audio from a video that I indicate in a path with a FFmpeg command, to do the service I have based on the following answer and I have adapted it to C #: https://stackoverflow.com/a/37422688/8496520
The problem is that when I try to execute the command I get the following error:
"NSInvalidArgumentException: launch path not accessible"
And I can't find out why this happens, I use the following code in the service (The error occurs when calling the Launch () method of the NSTask):
public void ExecuteFFmpeg()
{
try
{
var launchPath = NSBundle.MainBundle.PathForResource("ffmpeg", ofType: "");
var compressTask = new NSTask();
compressTask.LaunchPath = launchPath;
compressTask.Arguments = new string[] {
"-i",
"downloads/tyson.mp4",
"-c",
"copy",
"-an",
"nosound.mp4" };
compressTask.StandardInput = NSFileHandle.FromNullDevice();
compressTask.Launch();
compressTask.WaitUntilExit();
}
catch (Exception ex)
{
}
I have also uploaded the project to GitHub in case someone needs to consult the repository in its entirety: https://github.com/nacompllo/FFmpegSample