Permissions – Fix ‘Permission Denied’ with FFmpeg on External Drive

external-hddffmpegfstabpermissionssnap

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

Best Answer

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
Related Question