I'm trying to use my Canon DSLR as a webcam.
This is the command I have running in the background, in order to get a /dev/video0:
$ gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv422p -threads 0 -f v4l2 /dev/video0
This works, kind of, but I get fps between 4 and 5. I'd like to get better than that, I'm ok to sacrifice image resolution.
Here is the output of the command above:
Capturing preview frames as movie to 'stdout'. Press Ctrl-C to abort.
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[mjpeg @ 0x55bae133d9c0] 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, yuvj422p(pc, bt470bg/unknown/unknown), 960x640, 25 tbr, 1200k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> rawvideo (native))
[swscaler @ 0x55bae138a4e0] deprecated pixel format used, make sure you did set range correctly
Output #0, v4l2, to '/dev/video0':
Metadata:
encoder : Lavf57.83.100
Stream #0:0: Video: rawvideo (Y42B / 0x42323459), yuv422p, 960x640, q=2-31, 245760 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc57.107.100 rawvideo
frame= 719 fps=4.5 q=-0.0 Lsize=N/A time=00:00:28.76 bitrate=N/A speed=0.182x
I've searched for the warnings, but one seemed expected and ok, not sure about Format mjpeg detected only with low score of 25.
Is it possible to get better fps? the resolution seems to be 960x640, I think it's physically possible even on USB2?
I think that the issue is not in ffmpeg, rather before that, because letting gphoto2 output to the terminal, I feels that updates are also about 4 per second. Just a feel though.