I'm attempting to record a 1080 @ 30FPS video from a Logitech C920 webcam. Simple, right? Well, apparently not.
First, I tried on my desktop running 16.04 using Ubuntu's built-in Cheese application. The preview streams perfectly fine at 30FPS, but as soon as I start recording, the frame rate drops drastically to probably around ~15FPS (I don't know exactly since Cheese doesn't provide an FPS meter).
Next, I tried again on my desktop running 16.04 using guvcview
. Unfortunately, the version in the default repos for 16.04, 2.02
, has a bug which causes it to record video as a single still frame. Arghh... so then I installed 2.05
from an unofficial PPA. This solved the aforementioned bug, however, when I go to record video (using H.264 from the camera's hardware encoder) the first second or so of the video records perfectly, but then the frame rate drops to between 3 and 5 FPS.
Finally, to make sure it wasn't just a problem with my desktop, I installed guvcview
version 2.05
on my laptop running 18.04, but once again, when I go to record video (using H.264 from the camera's hardware encoder) the first second or so of the video records perfectly, but then the frame rate drops to between 3 and 5 FPS.
So what the heck is going on here? Is this an issue with libuvc
compatibility with the Logitech C920? I know it's not an issue of under-powered hardware, as I have a 6-core AMD CPU in my desktop and a quad-core 3rd gen i7 in my laptop.
I figured out how to make it work with
guvcview
.I found this post which mentioned that the issue was that
guvcview
was re-encoding the stream from the camera. Why that caused the horrible frame rate drop is a mystery to me, given that my CPU usage was extremely low...Anyway, the fix is to tell
guvcview
to use the raw stream from the camera:Please note that the format you tell the program to re-encode (or not) to is totally separate from the format you tell it to stream from the camera:
Also, on another note, it seems that either I have no idea how to tune the huge number of H.264 parameters in
guvcview
, or that the hardware H.264 encoder in the Logitech C920 is just really not that good. I recorded a 1080p30 clip in MJPEG (which resulted in about 60Mb/s of data) and transcoded it into 10Mb/s H.264 using Veags Pro on my Windows box, and the result was vastly superior to streaming from the webcam directly in H.264, also at 10Mb/s.