I am trying to set up my nikon d7000 dslr as a video device for Ubuntu 18.04, as shown in this article.
When I try to start the video stream/device with
gphoto2 --capture-movie --stdout | ffmpeg -loglevel verbose -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0
The Error I get:
:~$ gphoto2 --capture-movie --stdout | ffmpeg -loglevel verbose -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video0
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
Capturing preview frames as movie to 'stdout'. Press Ctrl-C to abort.
[mjpeg @ 0x5556d09cd9c0] 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, 1 reference frame, yuvj422p(pc, bt470bg/unknown/unknown, center), 640x426, 25 tbr, 1200k tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> rawvideo (native))
[graph 0 input from stream 0:0 @ 0x5556d09e0cc0] w:640 h:426 pixfmt:yuvj422p tb:1/1200000 fr:25/1 sar:0/1 sws_param:flags=2
[auto_scaler_0 @ 0x5556d09e88e0] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x5556d09e5e60] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format'
[swscaler @ 0x5556d09e99c0] deprecated pixel format used, make sure you did set range correctly
[auto_scaler_0 @ 0x5556d09e88e0] w:640 h:426 fmt:yuvj422p sar:0/1 -> w:640 h:426 fmt:yuv420p sar:0/1 flags:0x4
[v4l2 @ 0x5556d09d7980] ioctl(VIDIOC_G_FMT): Invalid argument
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Error initializing output stream 0:0 --
Conversion failed!
Info about the Camera:
:~$ gphoto2 --auto-detect
Model Port
----------------------------------------------------------
Nikon DSC D7000 (PTP mode) usb:001,005
:~$ gphoto2 --summary
Camera summary:
Manufacturer: Nikon Corporation
Model: D7000
Version: V1.03
Serial Number:
Vendor Extension ID: 0xa (1.0)
Vendor Extension Description: microsoft.com: 1.0
Capture Formats: JPEG Undefined Type
Display Formats: JPEG, Undefined Type, Association/Directory, DPOF, Script, Apple Quicktime
Device Capabilities:
File Download, File Deletion, File Upload
Generic Image Capture, No Open Capture, Nikon Capture 1, Nikon Capture 2, Nikon Capture 3
[...]
I spent some time in the man pages of these commands, without luck. I am still not sure where the problem is exactly. The camera appears to be sending a stream, at least the mirror goes up and when I try the command without the ffmpeg stuff I get a Terminal full of Garbage, witch is Image data in Text form, I presume.
Maybe I set the v4l2 device up wrong?
How can I check what is working and what is not? Maybe I have to tell the v4l2 exactly what it should do?
Can anybody help me with gphoto + ffmpeg + video4linux or point me in the right direction?
Did you check that /dev/video0 was the right device to use ?
I tested this kind of setup an found that I had 3 video devices.
/dev/video0 is my laptop's webcam. I don't know what /dev/video1 is.
/dev/video2 is my dslr through gphoto2.
I launched gphoto2 with this command and everything worked as intended.
Maybe you have a bug which have been fixed in eoan packages. I run :
Try
rmmod v4l2loopback
and then list all video devices usingls /dev/video*
and note all devicesmodprob v4l2loopback
and then list all video devices again usingls /dev/video*
see which device is been added compared to the output you got in #1 and use that newly added device in your gphoto2 commandI was having this same problem with a Canon EOS RP; I did every step correctly but the error kept appearing to me.
So I changed the camera setting from video (shooting) mode to photo mode and everything works fine.