4

I'm capturing video from my webcam with the following command:

ffmpeg -r 30 -f v4l2 -video_size 160x120 -i /dev/video0 output.avi

The -r option indicate the framerate I want. However, it's not that I want 30 FPS, it's just that otherwise it does not work correctly.

Without framerate, the capture is very buggy (I guess it tries to capture too much, but can't follow).

With a framerate set to 15, the output video is twice longer that the capturing duration (kind of slow motion).

With a framerate set to 30, it seems to be allright.

How can I be sure that I should use 30 fps? If i'd like to capture 15 fps, what should I do to get a correct playback?

Info about my webcam:

co@macbook2008:~$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
  Index       : 0
  Type        : Video Capture
  Pixel Format: 'YUYV'
  Name        : YUV 4:2:2 (YUYV)
    Size: Discrete 160x120
      Interval: Discrete 0.033s (30.000 fps)
      Interval: Discrete 0.036s (27.500 fps)
      Interval: Discrete 0.040s (25.000 fps)
      Interval: Discrete 0.044s (22.500 fps)
      Interval: Discrete 0.050s (20.000 fps)
      Interval: Discrete 0.057s (17.500 fps)
      Interval: Discrete 0.067s (15.000 fps)
      Interval: Discrete 0.080s (12.500 fps)
      Interval: Discrete 0.100s (10.000 fps)
      Interval: Discrete 0.133s (7.500 fps)
      Interval: Discrete 0.200s (5.000 fps)
    Size: Discrete 176x144
      Interval: Discrete 0.033s (30.000 fps)
      ... and so on for other resolutions

Thank you

chocopoche
  • 141
  • 1
  • 2
  • If I were to hazard a guess. The source video is also 30 fps. The output of the command you issued confirms this. – Ramhound Apr 03 '15 at 11:05
  • How does it confirm, as there are many fps? The first one is used? – chocopoche Apr 03 '15 at 11:18
  • I don't understand. You issued a command `v4l2-ctl --list-formats-ext` and the output indicates the supported frame rate and resolution of the source device It literally indicates that 30 fps is the highest it will support. – Ramhound Apr 03 '15 at 11:23
  • You could also set the fps to 27.5 if you wanted by changing the value and issuing the following command: `ffmpeg -r 27.5 -f v4l2 -video_size 160x120 -i /dev/video0 output.avi` – Ramhound Apr 03 '15 at 11:27
  • When I do `ffmpeg -r 15 -f v4l2 -video_size 160x120 -i /dev/video0 output.avi` for 15 seconds, I've got an avi of 30 seconds. So the `v4l2-ctl --list-formats-ext` says I can capture at 15 fps, but I won't be able to play it at the right speed. I guess the same applies for 27.5 fps, but I'm not able to test that for sure. – chocopoche Apr 03 '15 at 11:35

0 Answers0