3

I'm trying to record some videos using a USB camera, but I'm having some issues when using ffmpeg.

If I run ffmpeg -f video4linux2 -t 00:00:10 -i /dev/video0 out.mpg, the program tries to record at 640x480 resolution and ffmpeg hangs.

However, if I add the -s to ffmpeg and record at lower resolutions than 640x480 (e.g., 320x240), the video is recorded successfully.

After a hang, if I hit CTRL+C, ffmpeg resumes, yielding a file of 0 kB in size. Using strace I can see that an ioctl call to the device keeps returns -EINVAL and subsequent ioctls return -EAGAIN.

ioctl(3, VIDIOC_G_STD, 0xbe84dfb0)      = -1 EINVAL (Invalid argument)
ioctl(3, VIDIOC_DQBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE}) = -1 EAGAIN (Resource temporarily unavailable)

Any ideas why this happens?

I'm using ffmpeg version 2.8.7, built through busybox 1.25. The host architecture is an ARM processor running kernel 3.2.

I also tried compiling the most recent version from source, and the problem persists...

1

Figured out the reason: transcoding and raw data volume.

Using the command line mentioned in my question I was reading from a raw format (yuv422), and transcoding it to mpeg-1, which was the default encoding for my version of ffmpeg. The data amount being streamed from the camera was simply too much for the processor, causing the hang. The camera I was using was capable of streaming in a compressed format as well (mjpeg). By switching to this format, ffmpeg no longer hanged, and was capable of recording at 15 fps.

However, there was a transcoding step, from mjpeg to mpeg-1. I was able to reach a higher fps count by telling ffmpeg to copy the stream, removing the last transcoding step.

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.