1

To record video from my USB webcam I use ffmpeg with v4l2 driver (command below).

ffmpeg -f v4l2 -r 30 -s 640x480 -an -sn -i /dev/video0 -f avi temp

Unfortunately fps is too low for 640x480 (around 5 fps). During recording, ffmpeg loads the cpu by 6%. I tried to change the resolution to 1920x1080, but FPS has not changed and cpu load increased to 20%.

How to fix it?

0

Framerate can be limited by either the CPU performance (how fast the RPi can accept the frames), by the stream format (how fast can a webcam produce given frames), or by ambient conditions (low light requiring long exposition time). Since the CPU load in your first case is low, it looks like the problem is of the second/third kind.

Check out what video stream formats your webcam supports by running

v4l2-ctl --list-formats-ext

and pick a format which has high enough FPS. If you still get low FPS, try pointing your webcam at a light source and see if that increases the FPS. If that helps, you need to provide more light in the scene you're capturing, or buy a webcam which works better in the dark (expensive models often do).

  • I tried to change ambient conditions, but looks like it doesn't make any sense. – Данил Вагапов Jan 14 at 17:53
  • My webcam supports only YUYV pixel format. Format list: Index : 0 Type : Video Capture Pixel Format: 'YUYV' Name : YUYV 4:2:2 Size: Discrete 640x480 Interval: Discrete 0.033s (30.000 fps) [video4linux2,v4l2 @ 0x1c293b0] Raw : yuyv422 : YUYV 4:2:2 : 640x480 320x240 176x144 1024x768 1280x720 1280x1024 1600x904 1600x1200 – Данил Вагапов Jan 14 at 17:57
  • @ДанилВагапов I hope you meant to say "doesn't make any difference" :) Anyhow, it seems that your webcam should be able to output 640x480 at 30fps but it doesn't. Can you add to your question which brand and model it is, and also put the format list in your question? (it will also bump your question and attract more eyes to it) – Dmitry Grigoryev Jan 15 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.