Posts: 5
Joined: Thu Mar 13, 2014 3:06 pm

Maximizing webcam FPS

Thu Mar 13, 2014 3:27 pm

A couple weeks back I combined a PS3 Eye webcam with a Rev 1 Model B Pi (256MB) to act as a 'finish line' camera for a Cub Scout Pinewood Derby. The Eye, along with all other peripherals like mouse, keyboard, were hooked up to a powered USB hub. The camera itself is capable of up to 120fps at 320x240, but I couldn't get the Pi to grab more than 75fps.

The setup was:

Code: Select all

    #    Set resolution
    v4l2-ctl --set-fmt-video=width=320,height=240
    #    Set frames per second
    v4l2-ctl --set-parm 75
And I recorded with the command line:

Code: Select all

  ffmpeg -f video4linux2 -input_format yuyv422 -i /dev/video0 -vcodec copy output.mkv
The intent was to grab the raw camera video (hence "yuyv422" and "copy") and dump it to a file. All triggering was manual, by queuing up a script and hitting 'return' at the right time. It would take right around two seconds for ffmpeg to get going and actually start recording, but after that it would report 74-75 fps.

I used "mplayer" to play the resulting video, pausing and going frame-by-frame as the cars got to the finish line. The Pi - using mplayer, at least - couldn't play the video at full speed, but rather pegged the CPU and hit maybe 40fps.

This was adequate for a Pinewood Derby. Only one or two races out of many dozen was actually too close to call by the video and had to be re-run.

Trying to grab video at 120fps resulted in errors. If I set the FPS to 90, it would record, but the actual FPS reported by ffmpeg varied from 75 up to maybe 86, and varied a lot. I figured a solid 75fps was better than a bursty stream.

Some Googling hasn't turned up any faster FPS than that with a Pi. I understand that the Pi camera board will eventually be capable of 90fps, but isn't yet. I was wondering if anyone's managed anything faster? If so, with what software and hardware? Any suggestions for improvements for next year?

Return to “Graphics, sound and multimedia”