9

I got a new drive and I can copy files fine with simple cp on the drive. However for some weird reason I get Permission denied with ffmpeg.

Permissions seem fine unless I'm missing something

> ll /media/manos/6TB/
drwxrwxrwx  13 manos      4096 Apr 16 00:56  ./
drwxr-x---+  6 manos      4096 Apr 16 00:49  ..
-rwxrwxrwx   1 manos 250900209 Apr 15 17:28  test.mp4*
..

But ffmpeg keeps complaing

> ffmpeg -i test.mp4 test.mov
ffmpeg version n4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
  configuration: --prefix= --prefix=/usr --disable-debug --disable-doc --disable-static --enable-avisynth --enable-cuda --enable-cuvid --enable-libdrm --enable-ffplay --enable-gnutls --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopus --enable-libpulse --enable-sdl2 --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-nonfree --enable-nvenc --enable-omx --enable-openal --enable-opencl --enable-runtime-cpudetect --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-xlib
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
test.mp4: Permission denied

Simply copying like below works fine..

> cp test.mp4 test.mp4.bak
'test.mp4' -> 'test.mp4.bak'

Any ideas on what is going on? This is pretty annoying. Note ffmpeg is installed at /snap/bin/ffmpeg

4 Answers 4

15

So after a lot of digging I figured the issue is with snap package manager. Apparently by default, snap can't access the media directory so we need to manually fix this.

Check if ffmpeg has access to removable-media like below

> snap connections | grep ffmpeg
desktop                   ffmpeg:desktop                             :desktop                          -
home                      ffmpeg:home                                :home                             -
network                   ffmpeg:network                             :network                          -
network-bind              ffmpeg:network-bind                        :network-bind                     -
opengl                    ffmpeg:opengl                              :opengl                           -
optical-drive             ffmpeg:optical-drive                       :optical-drive                    -
pulseaudio                ffmpeg:pulseaudio                          :pulseaudio                       -
wayland                   ffmpeg:wayland                             :wayland                          -
x11                       ffmpeg:x11                                 :x11                              -

Add that permission if it's missing

sudo snap connect ffmpeg:removable-media
0

For anyone googling the permission issue and seeing this thread:

In my case, the problem was that in my code, I didn't close the files had just created in the same method before passing them on to ffmpeg. So if ffmpeg crashes with permission denied, make sure that any open file handles have been closed.

0

ffmpeg via snap seems to in some kind of snap confinement, where only certain directories are brought into snap.

Currently ( April 2023 ) it's hardcoded that /media and /home/$USER are brought, everything else will not work (think of chroot ).

See more information here: https://askubuntu.com/a/1040278/32777 , especially the comment section

-1

Add sudo before your commands. It works for me.

1
  • 4
    While this may work it would be a better answer if you could explain why running as root is necessary in this case. Commented Apr 16, 2020 at 3:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .