2

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?

3
  • Two posts today about the same error. I suspect a problem with v4l2loopback (but I'm not sure). Try removing the v4l2loopback-dkms package and compile v4l2loopback. – llogan Apr 9 '20 at 22:02
  • Indeed, ther might be a bug .. github.com/umlaeute/v4l2loopback/issues/… – Valentin H. Apr 11 '20 at 10:04
  • It may be an issue with v4l2loopback. I run Ubuntu eoan (which is newer than yours) and I added the release numbers of my ffmpeg and vl2loopback (whitch are OK) to my answer. – ChrisAga Apr 11 '20 at 12:36
0

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.

gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video2

Maybe you have a bug which have been fixed in eoan packages. I run :

  • ffmpeg 7:4.1.4-1build2
  • v4l2loopback 0.12.2-1
2
  • No, the outcome is the same, regardless of what video out I specify. Also there is no other camera on this PC (not a laptop) – Valentin H. Apr 11 '20 at 10:00
  • You will still get the same error: [mjpeg @ 0x740a940] Format mjpeg detected only with low score of 25, misdetection possible! – Jamie Hutber Jul 25 '20 at 11:30
0

Try

  1. Run rmmod v4l2loopback and then list all video devices using ls /dev/video* and note all devices
  2. Run modprob v4l2loopback and then list all video devices again using ls /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 command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.