Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always Get Camera error #78

Open
pahan40 opened this issue Aug 8, 2018 · 10 comments
Open

Always Get Camera error #78

pahan40 opened this issue Aug 8, 2018 · 10 comments

Comments

@pahan40
Copy link

pahan40 commented Aug 8, 2018

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.

@sadjad
Copy link
Member

sadjad commented Aug 8, 2018

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

@pahan40
Copy link
Author

pahan40 commented Aug 9, 2018

Already tried - no effect

@sadjad
Copy link
Member

sadjad commented Aug 9, 2018

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

@pahan40
Copy link
Author

pahan40 commented Aug 9, 2018

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

@sadjad
Copy link
Member

sadjad commented Aug 9, 2018

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

@pahan40
Copy link
Author

pahan40 commented Aug 15, 2018

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...

@jdelrue
Copy link

jdelrue commented Feb 20, 2019

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

@sadjad
Copy link
Member

sadjad commented Feb 20, 2019

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

@xiongxuecheng
Copy link

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.

@zhangxucan123
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants