Xabe.FFmpeg icon indicating copy to clipboard operation
Xabe.FFmpeg copied to clipboard

Permission denied exception. Downloaded ffmpeg and ffprobe files don't have +x premission.

Open Alyasko opened this issue 5 years ago • 6 comments

Hi.

When calling Xabe.FFmpeg.FFmpeg.GetLatestVersion() the files ffmpeg and ffprobe are downloaded to "." path, however on Linux these files don't have +x premission - hence permission denied exception occurs. Please fix.

Thank you.

Alyasko avatar Nov 13 '19 18:11 Alyasko

Hello,

As I know, to do that you will have to open your app with sudo permission. Don't know if it's a good way. I have to investigate topic, but this will take some time. Fell free to create Pull Request with changes :)

tomaszzmuda avatar Dec 04 '19 10:12 tomaszzmuda

Does anyone have a similar issue? I have tried to reproduce this but in my case, everything works fine without sudo.

tomaszzmuda avatar Feb 29 '20 00:02 tomaszzmuda

I have the same issue by using docker with Linux containers.

await FFmpeg.GetLatestVersion(Xabe.FFmpeg.Enums.FFmpegVersion.Official);

After the binaries are downloaded, I cannot perform/start any ffmpeg process/task because I get the following error:

System.ComponentModel.Win32Exception (13): Permission denied\n   at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)\n   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)\n   at System.Diagnostics.Process.Start()\n   at Xabe.FFmpeg.FFmpeg.RunProcess(String args, String processPath, Nullable`1 priority, Boolean standardInput, Boolean standardOutput, Boolean standardError)\n   at Xabe.FFmpeg.FFmpegWrapper.<>c__DisplayClass11_0.<RunProcess>b__0()\n   at System.Threading.Tasks.Task`1.InnerInvoke()\n   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\n--- End of stack trace from previous location where exception was thrown ---\n   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)\n--- End of stack trace from previous location where exception was thrown ---\n   at Xabe.FFmpeg.Conversion.Start(String parameters, CancellationToken cancellationToken)\n

Looking at the binaries permissions inside the Linux container, I found:

#ls -la
total 146200
drwxr-xr-x 2 root root     4096 Apr 30 22:22 .
drwxr-xr-x 1 root root     4096 Apr 30 21:23 ..
-rw-r--r-- 1 root root 74891136 Sep  7  2019 ffmpeg
-rw-r--r-- 1 root root 74793024 Sep  7  2019 ffprobe
-rw-r--r-- 1 root root       24 Apr 30 22:22 version.json

The files have no permissions to be executed.

After the permissions are assigned: chmod +x ffmpeg ffprobe Everything works fine.

It should be nice if these permissions were granted inside the logic of the GetLatestVersion method.

djosemartine avatar May 06 '20 18:05 djosemartine

The same issue here, using FFmpegVersion.Official running on macOS

micdah avatar Jun 30 '20 10:06 micdah

This might be useful to help use chmod on applicable systems: https://www.nuget.org/packages/Mono.Posix.NETStandard/1.0.0

Here's how I ended up "fixing" it in my code:

Syscall.chmod("ffmpeg", FilePermissions.S_IRUSR | FilePermissions.S_IWUSR | FilePermissions.S_IXUSR);
Syscall.chmod("ffprobe", FilePermissions.S_IRUSR | FilePermissions.S_IWUSR | FilePermissions.S_IXUSR);

micdah avatar Jun 30 '20 10:06 micdah

also the GetLatestVersion function is async so it's better to change it's name to GetLatestVersionAsync

dev-masih avatar Jul 22 '20 04:07 dev-masih