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):
- Pre-configure the camera: sudo v4l2-ctl --device=/dev/video0 --set-fmt-video=width=1280,height=720,pixelformat=1
- 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