I have been trying to setup my DSLR to be a webcam with the following command: gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -threads 0 -f v4l2 /dev/video0
this however results in the following error:
hutber@hutber:~/v4l2loopback-master$ gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -threads 0 -f v4l2 /dev/video4
ffmpeg version N-49161-g50e194e6e1-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gmp --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libdav1d --enable-libxvid --enable-libzvbi --enable-libzimg
libavutil 56. 30.100 / 56. 30.100
libavcodec 58. 53.101 / 58. 53.101
libavformat 58. 28.101 / 58. 28.101
libavdevice 58. 7.100 / 58. 7.100
libavfilter 7. 55.100 / 7. 55.100
libswscale 5. 4.101 / 5. 4.101
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Capturing preview frames as movie to 'stdout'. Press Ctrl-C to abort.
[mjpeg @ 0x6d04900] Format mjpeg detected only with low score of 25, misdetection possible!
Input #0, mjpeg, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 640x426, 25 tbr, 1200k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> rawvideo (native))
[video4linux2,v4l2 @ 0x6d07d00] Unable to open V4L2 device '/dev/video4'
Could not write header for output file #0 (incorrect codec parameters ?): No such file or directory
Error initializing output stream 0:0 --
Conversion failed!
However this errors to create the dummy device, that at the same time is not accessible
hutber@hutber:~/v4l2loopback-master$ v4l2-ctl --list-devices
Dummy video device (0x0000) (platform:v4l2loopback-000):
/dev/video2
Failed to open /dev/video0: No such file or directory
I would like the /dev/video0 to be available to use as a webcam and believe the issue lies somewhere in the v412.
[Edit]
After restarting the machine I now see:
hutber@hutber:~$ v4l2-ctl --list-devices
Failed to open /dev/video0: No such file or directory
It says there is a Dummy Video Device, but I cannot see any devices when trying to use the dummy video.
Unable to open V4L2 device '/dev/video0'
or
Failed to open /dev/video0: No such file or directory
Two potential problems:
video
number. The number can change depending on the number of existing webcams. Check output ofls /dev/video*
orv4l2-ctl --list-devices
.sudo modprobe v4l2loopback
. Then check output ofls /dev/video*
orv4l2-ctl --list-devices
. If you did not yet install it see Is there any way ffmpeg send video to/dev/video0
on Ubuntu?.Unknown V4L2 pixel format equivalent for yuvj422p
The V4L2 output device only supported a limited number of pixel formats. Add the format filter to your command to give it a compatible pixel format:
For me, the problem was that my
ffmpeg
was installed by snap and didn't originally have access to camera.Running
fixed it.