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

Issues with Logitech C510 on a Raspberry Pi #121

Open
jminardi opened this Issue Nov 15, 2017 · 6 comments

Comments

Projects
None yet
3 participants
@jminardi
Copy link

jminardi commented Nov 15, 2017

I am trying to get my Logitech C510 working with homebridge. I am running the Raspberry Pi fork of this repo: https://github.com/legotheboss/homebridge-camera-ffmpeg-omx

I know them camera is connected correctly:

pi@raspberrypi:~ $ lsusb
Bus 001 Device 004: ID 046d:081d Logitech, Inc. HD Webcam C510

I have also used this camera in the past with Octoprint on the raspberry pi.

I have also verified that ffmpeg is install correctly by running the demo code listed on this page:

/etc/ffserver.conf

Port 8090
# bind to all IPs aliased or not
BindAddress 0.0.0.0
# max number of simultaneous clients
MaxClients 10
# max bandwidth per-client (kb/s)
MaxBandwidth 1000
# Suppress that if you want to launch ffserver as a daemon.
NoDaemon

<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 10M
</Feed>

<Stream test.mjpg>
Feed feed1.ffm
Format mpjpeg
VideoFrameRate 4
VideoSize 600x480
VideoBitRate 80
# VideoQMin 1
# VideoQMax 100
VideoIntraOnly
NoAudio
Strict -1
</Stream>

/usr/sbin/webcam.sh

ffserver -f /etc/ffserver.conf & ffmpeg -v verbose -r 5 -s 600x480 -f video4linux2 -i /dev/video0 http://localhost:8090/feed1.ffm

Running /usr/sbin/webcam.sh produces a (slightly delayed and low framerate) livestream of my camera at <raspi_ip>:8090/test.mjpg

@jminardi

This comment has been minimized.

Copy link

jminardi commented Nov 15, 2017

More information that is probably useful, this is my entry in config.json:

{
	  "platform": "Camera-ffmpeg-omx",
	  "cameras": [
	    {
	      "name": "Livingroom",
	      "videoConfig": {
		"source": "-f mjpeg -i http://127.0.0.1:8090/webcam/?action=stream",
		"maxStreams": 2,
		"maxWidth": 640,
		"maxHeight": 480,
		"maxFPS": 30,
		"vcodec": "h264_omx"
	      }
	    }

I am able to find and add a camera in my Home app, but it only shows the crossed out camera icon.

@jminardi jminardi closed this Nov 15, 2017

@jminardi jminardi reopened this Nov 15, 2017

@idcrook

This comment has been minimized.

Copy link

idcrook commented Feb 9, 2018

I am trying to set up streaming for a Logitech C615 USB webcam running on same Pi 3 as homebridge, very similar to this scenario. I am not attempting to run the ffmpeg server separately, but instead using this homebridge plugin to access the video device on the same host's filesystem.

my config looks like the following, with homebridge user being in the video group that is required for accessing /dev/video*. Before I added the stillImageSource part, it also had a crossed-out camera icon in Home app. Using the stillImageSource, I do not have the crossed-out camera anymore, but all the snapshots the Home App displays are completely black.

      "cameras": [
        {
          "name": "BasementCam",
          "videoConfig": {
              "source": "-f v4l2 -r 30 -s 1280x720 -i /dev/video0",
              "stillImageSource": "-f v4l2 -s 1280x720 -i /dev/video0",
              "maxStreams": 2,
              "maxWidth": 1280,
              "maxHeight": 720,
              "maxFPS": 30,
              "vcodec": "h264_omx"
          }
        }

Is there something else I should try?

BTW, I do see statements like Feb 09 10:56:08 rpih1 homebridge[7736]: -f v4l2 -r 30 -s 1280x720 -i /dev/video0 -threads 0 -vcodec h264_omx -an -pix_fmt yuv420p -r 30 -f rawvideo -tune zerolatency -vf scale=1280:720 -b:v 299k -bufsize 299k -payload_type 99 -ssrc 1 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params 1LILJ0m46VCcYCJU38Q2GyyMpvSlM2PoSneEIx2E srtp://10.0.1.90:62623?rtcpport=62623&localrtcpport=62623&pkt_size=1378 ever so often in my systemd log for homebridge, if that helps to diagnose...

@idcrook

This comment has been minimized.

Copy link

idcrook commented Feb 9, 2018

BTW, I am able to confirm that ffmpeg itself on my Pi 3 (using the OMX HW support codec version) from the command line to output to a file with this camera works fine, i.e., speed faster than 1.0x.

# resolution 640x360
ffmpeg -f v4l2 -framerate 30 -video_size 640x360 -i /dev/video0 -pix_fmt yuv420p  -c:v h264_omx  output.mkv
<<...>>
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_omx))
<<...>>
frame=  223 fps= 17 q=-0.0 Lsize=     186kB time=00:00:14.70 bitrate= 103.7kbits/s speed=1.13x

# resolution 1280x720
ffmpeg -f v4l2 -framerate 30 -video_size 1280x720 -i /dev/video0 -pix_fmt yuv420p  -c:v h264_omx  output.mkv
<<...>>
[video4linux2,v4l2 @ 0x2744240] The driver changed the time per frame from 1/30 to 1/10
<<...>>
frame=  118 fps= 11 q=-0.0 Lsize=     291kB time=00:00:12.10 bitrate= 197.1kbits/s speed=1.13x
@idcrook

This comment has been minimized.

Copy link

idcrook commented Feb 9, 2018

After making a few changes to my config, the video stream through Home app has started working.
The snapshot facility is not yet working, but I will take a look at that next.
My config.js entry is the same as above

The two changes were:

  1. Increase gpu_mem in /boot/config.txt to 64 (was 16 previously in my setup)
  2. changed the USB port I plugged in webcam to
    • Before I did this I was getting disconnected USB for the webcam repeatedly in kernel logs (seen via dmesg)
    • I used one of the two ports further away from the Ethernet jack

Not sure if this will help OP, but this was one way to get homebridge-camera-ffmpeg-omx working with a "local" USB webcam.

@TannerH

This comment has been minimized.

Copy link

TannerH commented Feb 12, 2018

@idcrook This looks promising! I'm trying to use the same set-up with /dev/video0 instead of an rtsp stream. I had it working fine but it seems to die after a couple hours. Going to try the gpu_mem trick tonight and see if that helps. How stable has yours been since you got it up and running?

@idcrook

This comment has been minimized.

Copy link

idcrook commented Feb 13, 2018

It is not very reliable and often has a considerable startup latency. But when it starts working, it seems fine. Often when I try again after leaving Home app it works.

For addl. info I did a write here: http://github.crookster.org/Adding-A-Webcam-To-HomeKit/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment