Video capture from USB camera

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box
Tux.png Applies to Linux
Naon am387x-dm814x.png Applies to Naon

Introduction[edit | edit source]

This article describes various modes for capturing video from an USB camera.

System architecture[edit | edit source]

  • Board: NaonEVB-Mid
  • Camera: Webcam Logitech HD C310 720p (Product page)
  • Connection: USB Host 2.0

Video capture using FFmpeg and Video4Linux[edit | edit source]

Useful links[edit | edit source]

FFmpeg project page: http://ffmpeg.org/

Video4Linux wiki: http://linuxtv.org/wiki/index.php/Main_Page

Video4Linux kernel documentation: http://www.mjmwired.net/kernel/Documentation/video4linux/v4l2-framework.txt

Configuring the system[edit | edit source]

The FFmpeg tool is not provided with the default NELK root file system. FFmpeg can be added to the root file system:

  • manually, building it from source coder
  • using a build system, as buildroot or openembedded
  • installing it as a package, if the root file system features a package manager and ffmpeg is available as a package

In this article, we assume the use of a root file system built with Buildroot and customized adding the EZSDK components, as described in the Creating a RFS with Buildroot article. The FFmpeg package can be selected entering the Package selection for the target menuconfig option (see Creating_a_RFS_with_Buildroot#Configuring_Buildroot).

Before using the Video4Linux framework, it should be enabled in the kernel. The following options must be enabled:

  • Device Drivers->Multimedia support
  • Device Drivers->Video For Linux
  • Device Drivers->Video For Linux->Video capture adapters
  • Device Drivers->Video For Linux->Video capture adapters->V4L USB devices
  • Device Drivers->Video For Linux->Video capture adapters->V4L USB devices->USB Video Class (UVC)
  • Device Drivers->Video For Linux->Video capture adapters->V4L USB devices->UVC input events device support (NEW)


Enabling-v4l-usb.jpeg

Performing the capture[edit | edit source]

The video stream from the USB camera con be captured and saved to the out.avi file using the following command:

ffmpeg -f video4linux2 -r 30 -s 640x480 -i /dev/video0 out.avi

assuming that /dev/video0 is the webcam device file.

Video capture using gstreamer[edit | edit source]

This how-to will be reported soon.