5

Running Rasbian OS on Raspberry Pi B

From dmesg:

[139215.134634] usb 1-1.3: new high-speed USB device number 7 using dwc_otg
[139216.356892] usb 1-1.3: New USB device found, idVendor=046d, idProduct=082d
[139216.356929] usb 1-1.3: New USB device strings: Mfr=0, Product=2, SerialNumber=1
[139216.356946] usb 1-1.3: Product: HD Pro Webcam C920
[139216.356961] usb 1-1.3: SerialNumber: CF47B63

I followed this tutorial: https://www.raspberrypi.org/documentation/usage/webcams/

But when I type fswebcam image.jpg I get:

--- Opening /dev/video0...
stat: No such file or directory

My guess is that there are no drivers installed for the Logitech c920 on my pi, but I'm not sure. How would I download drivers or what should I do to be able to use my webcam? The c920 is on the list of approved webcams, I have nothing else being powered by my pi so I should have enough power output to take a simple picture.

skrhee
  • 175
  • 1
  • 1
  • 6

2 Answers2

5

I spent a number of hours recently with my C920 and a Raspberry Pi 3 recently to make a babyCam that I could stream within my home network. I may be able to shed some light but also provide documentation and experience to other users.

OK, to use the Video4Linux2 driver to find the camera's video device do this:

v4l2-ctl --list-devices

My experience:

  • I can decode the video on VLC on Mac (v2.2.4)
  • I can decode the video on VLC for iPhone
  • the playback URL in VLC is "rtsp://{ip_or_hostname_of_the_Pi}:8554/"
  • expect the audio to be heard first and typically about 5-10 seconds for the video to come through.
  • Add-on commercial decoders for Windows Media Player such as VBrick's StreamPlayer product should decode an rtsp transport stream. VBrick's playback url would be something like rtspu://{ip_or_hostname_of_the_Pi}:8554/" but I haven't tested it. The syntax can be a bit whacky.

The C920's H.264 encoder is good but its rate seems only works at 3 Mb/s average bit rate no matter what the resolution. However, I tend to use 720p, that is 1280x720 because a 16:9 aspect ratio makes sense for the application.

I have to transcode the raw audio and I found it tricky to get vlc 2.2.1 built for Raspbian to be tricky -- I end up using mp2a audio.

I do not recommend trying to transcode the video because then the Pi's CPU's go working on overtime.

VLC has a delay of 1-3 seconds.

VLC's rtp server seemed lousy. VLC's Transport Stream (ts) is decent. These steps are for using the camera's internal H.264 encoder (pixelformat=1):

  1. Pre-configure the camera: sudo v4l2-ctl --device=/dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=1
  2. cvlc -I dummy v4l2:///dev/video0:chroma=h264:width=1280:height=720 :input-slave="alsa://plughw:CARD=C920,DEV=0" --sout '#transcode{acodec=mp2a,ab=96,channels=2}:rtp{sdp=rtsp://:8554/,mux=ts}' -v

the audio was more difficult than the video. To test audio you can try to use alsa's arecord. I used

arecord -L

to get the device names. Now, I found the name "plughw:CARD=C920,DEV=0" which arecord described as "Hardware device with all software conversions"

On testing the camera's audio, I recorded and listened to the WAV file I recorded to the Pi's local storage. Unfortunately with this recipe, you'll need to Ctrl-C after 10 seconds. Cleanup the extra record files. So I can record good sound from the camera with this command to a wav file but I can't make arecord stop at 10 seconds:

arecord -d 10 -t wav -D plughw:CARD=C920,DEV=0 -f cd --max-file-time 10 recordcam.wav
Jim Russell
  • 51
  • 1
  • 3
4

Could it be something as simple as the camera being recognized as something other than /dev/video0? Does ls /dev/video* yield anything else?

It's been many months since I used a C920 on my Raspberry Pi, but at the time, everything "just worked" so long as I used the right device.

bobstro
  • 3,978
  • 15
  • 27