FFMPEG permission denied trying to covert video

This problem started for me on 18.04, and I tried to fix it then, unsuccessfully. I've recently upgraded to 21.04 on a new hardware and the problem persists.

I installed ffmpeg 4.3.1 from the Ubuntu Software app I also have installed Ubuntu restricted extras Below is an example of a command that fails. But even BASH scripts that worked before also fail with the same error.

~$ ffmpeg -i /mnt/Data/Videos/192.168.1.2_Street_main_20210522141323_141716-5fnd662.avi -ss 1 -t 95 /mnt/Data/Videos/192.168.1.2_Street_main_20210522141323_141716-5fnd662.mp4

/usr/share/libdrm/amdgpu.ids: No such file or directory
ffmpeg version n4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --prefix= --prefix=/usr --disable-debug --disable-doc --disable-static --enable-cuda --enable-cuda-sdk --enable-cuvid --enable-libdrm --enable-ffplay --enable-gnutls --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libmp3lame --enable-libnpp --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. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
/mnt/Data/Videos/192.168.1.2_Street_main_20210522141323_141716-5fnd662.avi: **Permission denied**

First, run the following commands to fix the file not found error:

sudo apt update
sudo apt install libdrm-common

Whenever you get a file not found error, you can use apt-file to try and locate the package that provides the needed file.

sudo apt update
sudo apt install apt-file
sudo apt-file update
apt-file search /usr/share/libdrm/amdgpu.ids

It might take a while but it should return the following:

libdrm-common: /usr/share/libdrm/amdgpu.ids

This is how I determined which package to install.


Next, it appears you don't have write permission on your mounted directory.

You can either remount the mounted filesystem with write permissions or you can copy the .avi file to your user's $HOME directory before you execute ffmpeg.

For example, you can copy the file to your user's Desktop directory:

cp /mnt/Data/Videos/192.168.1.2_Street_main_20210522141323_141716-5fnd662.avi $HOME/Desktop

and then run ffmpeg from there:

ffmpeg -i ~/Desktop/192.168.1.2_Street_main_20210522141323_141716-5fnd662.avi -ss 1 -t 95 ~/Desktop/192.168.1.2_Street_main_20210522141323_141716-5fnd662.mp4

If you still get a permission denied error, you can change ownership of the file:

sudo chown $USER:$USER ~/Desktop/192.168.1.2_Street_main_20210522141323_141716-5fnd662.avi

and then try again:

ffmpeg -i ~/Desktop/192.168.1.2_Street_main_20210522141323_141716-5fnd662.avi -ss 1 -t 95 ~/Desktop/192.168.1.2_Street_main_20210522141323_141716-5fnd662.mp4