How to capture the H.264 stream of a Logitech c920 camera

encodingquicktimevideowebcam

I am using a Logitech c920 HD Pro Webcam with my Macbook Pro 17" (early 2011) and Mac OS Mavericks 10.9.5

I am able to record videos with Quicktime 10.3 where I have two options for "quality" with this camera: high or maximum.

The file size gets very large, especially in "maximum" where 80 seconds in an black and white (colour setting to 0) take up 2.6 GB already.

I think this camera is providing a H.264 stream which already should be compressed much more but Quicktime seems not to be able to load from that stream.

Also, the quality of the video seems to be rather blurry and not really Full HD.

I tried to install Final Cut Pro because there where some links on the net that provided this tip. With Final Cut Pro in its test version come several codecs that might provide a solution. But Final Cut Pro is not any more compatible with Mavericks.

Any hints how to capture the pre-compressed stream from the camera instead of the raw material?

Best Answer

This is a partial answer, but from what I recall the C920 doesn't stream in H264 by default. I think it defaults to MJPEG (which would explain the blurriness), the 3rd option being YUV.

If you follow this thread, you'll see that I had to change the streaming mode using v4l2ctl (in Linux) to obtain a H264 stream. Assuming you've got a Linux computer somewhere:

#this sets the C920 cam to H264 encoding, framerate 30/1:
v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=1 

Hopefully, the configuration remains after unplugging the webcam, allowing you to use it on OSX...

If you're interested in a less "native" solution than QuickTime, the rest of the thread describes how to use gstreamer, either by rtp streaming or local capture. I didn't try it on OSX but you can try replacing v4l2src by osxvideosrc:

gst-launch-1.0 -vvv osxvideosrc \
! video/x-h264, width=1920, height=1080, framerate=30/1 \
! queue max-size-buffers=1 \
! matroskamux \
! filesink location=/tmp/video.mkv

... which should give you a Matroska file.