/Webcam-SDL2

A demo illustrating capturing video using v4l2 and displaying with SDL2

Primary LanguageCMIT LicenseMIT

Webcam-SDL2

Build Status

Intro

This is a simple example which illustrates how to capture video(or image if you like) using v4l2 and to display with SDL2.

Currently, most webcams supports YUYV422 output format. So the default output format is set to YUYV422. You can modify the format parameter both for v2lc and sdl2 to be compatible with your webcam.

To list support formats of your webcam, try following commands:

v4l2-ctl --list-formats-ext

or if ffmpeg installed

ffmpeg -f v4l2 -list_formats all -i /dev/video0

Usage

Both Makefile and CMakeLists are provided.

  • using Makefile
git clone https://github.com/chendotjs/Webcam-SDL2
cd Webcam-SDL2/src
sudo apt-get install libsdl2-dev
make
./simple_cam 640 480 /dev/video0
  • using CMakeLists
git clone https://github.com/chendotjs/Webcam-SDL2
cd Webcam-SDL2/
sudo apt-get install libsdl2-dev
mkdir build && cd build
cmake ../src
make
./simple_cam 640 480 /dev/video0

References

fswebcam

CAPTURING A WEBCAM STREAM USING V4L2

最简单的视音频播放示例1:总述