snapcrafters / ffmpeg

Record, convert, and stream audio and video
9 stars 9 forks source link

FFmpeg cannot access /dev/video0 #44

Closed veikk0 closed 4 years ago

veikk0 commented 4 years ago

When attempting to record video from a v4l2 device (in this case /dev/video0), this Snap version of FFmpeg fails with an "Operation not permitted" error.

Example of a command that fails on a laptop with a webcam: /snap/bin/ffmpeg -f v4l2 -input_format mjpeg -framerate 30 -video_size 320x240 -i /dev/video0 -t 5 -pix_fmt yuv420p -c:v libx264 -preset ultrafast -y output.mkv

Error output by FFmpeg: [video4linux2,v4l2 @ 0x56022971e100] Cannot open video device /dev/video0: Operation not permitted /dev/video0: Operation not permitted

Version installed from the repositories (/usr/bin/ffmpeg) works as expected.

popey commented 4 years ago

If you snap connect ffmpeg:camera does the problem go away?

veikk0 commented 4 years ago

Yes, this fixed the issue.

fhiggins commented 4 years ago

I have a similar problem. The solution above worked for the video channel. However, I have a separate USB microphone. The driver, etc. works - other apps can access it. Is there a similar command for the audio. I tried: sudo snap connect ffmpeg:alsa which would not work. Here's the output when trying to show alsa sources: ffmpeg -sources alsa Error: unable to open display 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 Auto-detected sources for alsa: ALSA lib conf.c:3916:(snd_config_update_r) Cannot access file /usr/share/alsa/alsa.conf Cannot list sources.