alfalfa icon indicating copy to clipboard operation
alfalfa copied to clipboard

Always Get Camera error

Open pahan40 opened this issue 6 years ago • 10 comments

When I Try to launch sender I got something like this. salsify-sender --device /dev/video0 127.0.0.1 10002 1337 terminate called after throwing an instance of 'std::runtime_error' what(): couldn't configure the camera with the given format zsh: abort salsify-sender --device /dev/video0 127.0.0.1 10002 1337

I Tried 3 web cameras, no one worked.

pahan40 avatar Aug 08 '18 11:08 pahan40

Hi @pahan40,

Try using --pixfmt NV12 or --pixfmt YUYV or --pixfmt YU12. Those are the only three pixel formats that are implemented (check out src/input/camera.hh).

Best, Sadjad

sadjad avatar Aug 08 '18 19:08 sadjad

Already tried - no effect

pahan40 avatar Aug 09 '18 07:08 pahan40

Can you try running v4l2-ctl --device /dev/video0 --list-formats to see what formats your camera supports? (It's in v4l2-utils package in Ubuntu).

--Sadjad

sadjad avatar Aug 09 '18 16:08 sadjad

Here it is

[19:58:40] [pavel]<pavel>% v4l2-ctl --device /dev/video0 --list-formats
ioctl: VIDIOC_ENUM_FMT
        Index       : 0
        Type        : Video Capture
        Pixel Format: 'YUYV'
        Name        : YUYV 4:2:2

        Index       : 1
        Type        : Video Capture
        Pixel Format: 'MJPG' (compressed)
        Name        : Motion-JPEG

pahan40 avatar Aug 09 '18 16:08 pahan40

That's weird, it should work with --pixfmt YUYV, but for some reason it doesn't. Try running v4l2-ctl --list-framesizes=YUYV to make sure your camera supports 1280x720 (it most likely does, but doesn't hurt to check.)

I suggest you try getting real-webcam program (in src/salsify/) to run. The command line arguments are similar to salsify-sender.

Based on the information you posted here, this should work for you: real-webcam --device /dev/video0 --pixfmt YUYV

If none of the above worked, I might have a hack that works for you.

  1. Make sure you have ffmpeg installed.
  2. Try running ffplay -i /dev/video0 -f v4l2 -s 1280x720 -input_format mjpeg to make sure ffmpeg can actually read from your camera.
  3. Install v4l2loopback-dkms package. It allows you to create a fake webcam.
  4. Run modprobe v4l2loopback to start the fake camera module. Now, you'll see that a /dev/videoX device is added (probably /dev/video1, if you only have one camera).
  5. Use ffmpeg to forward your webcam to that fake webcam, in a format that Salsify expects: ffmpeg -f v4l2 -input_format mjpeg -r 30 -s 1280x720 -i /dev/video0 -vcodec rawvideo -pix_fmt yuv420p -f v4l2 /dev/video1
  6. Confirm that real-webcam program works: real-webcam --device /dev/video1 --pixfmt YU12
  7. Now you can use salsify-sender.

Please let us know how it goes!

--Sadjad

sadjad avatar Aug 09 '18 17:08 sadjad

Yes. Seems that command works fine real-webcam --device /dev/video1 --pixfmt YU12 and also salsify-sender now works fine, but the picture from camera always freeze for a few seconds and seems it works very slow...

pahan40 avatar Aug 15 '18 18:08 pahan40

got the same error

ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Pixel Format: 'MJPG' (compressed) Name : Motion-JPEG

Index : 1 Type : Video Capture Pixel Format: 'YUYV' Name : YUYV 4:2:2

jdelrue avatar Feb 20 '19 09:02 jdelrue

Have you tried running salsify-sender with --pixfmt YUYV flag?

sadjad avatar Feb 20 '19 17:02 sadjad

I met same problem in my scenario, after checking my camera format by "v4l2-ctl -d /dev/video0 --all" : Format Video Capture: Width/Height : 640/480 Pixel Format : 'YUYV'

Then I change code in "salsify-sender.cc" to adjuct width and height from hard code "1280 720" to "640 480" , it works fine then. But the received video don't have colors but only gray video displayed.

xiongxuecheng avatar Mar 20 '19 07:03 xiongxuecheng

I met same problem in my scenario, after checking my camera format by "v4l2-ctl -d /dev/video0 --all" : Format Video Capture: Width/Height : 640/480 Pixel Format : 'YUYV' Then I change code in "salsify-sender.cc" to adjuct width and height from hard code "1280 720" to "640 480" , it works fine then. But the received video don't have colors but only gray video displayed.

I'm same with you.the received video don't have colors but only gray video displayed, I wonder if you have solved the problem?

zhangxucan123 avatar Dec 02 '19 14:12 zhangxucan123