Video devices :
Linux does not allow several applications to connect on the same video device.
In a robotics system you want to use the same camera with several applications at the same time. So we use a video loopback which creates a virtual video device. This virtual loopback video device authorizes several applications to be connected simultaneously.
You shall connect on these virtual loopback video device. The hardware video devices are already utilized by the loopbacks, so you cannot use them.
Ubuntu 12.04 does not include v4l2loopback package do we developed our own loopback : fakecamera process
Reeti has a "fakecamera" /dev/video2 which is a virtual fake device of /dev/video0
The other camera does not have any loopback. You can connect directly on the webcam video device : /dev/video1
So :
- /dev/video0 is not accessible (it is already used by fakecamera process)
- /dev/video1 is accessible by only one client : however, considering usb 2.0 controlers flow limitation, the maximum configuration is 320x240 at 10 fps
- /dev/video2 is accessible by several clients : configuration is set to 25 fps, 640x480 resolution
Video Streaming (with VLC)
Reeti :
- Open VLC
- Go to Media -> Stream
- Choose /dev/video2 as input device
- Click on "Stream"
- Add a RTSP destination, for example on port "8554" and path "/"
- Activate transcoding and choose the profile "Video - MPEG-2"
- Modify the transcoding options : bitrate : 2000kb/s ; framerate : 25fps
- Steam
Client :
- Open VLC
- Go to Media -> Open network stream
- Choose rtsp://ip-of-reeti:8554/
- Play
Remarks :
- Reducing the "Caching" duration on both host and client can reduce the latency
How to record video and audio
You can use your favourite linux application or library.
Here is the example with ffmpeg :
ffmpeg -f video4linux2 -s 640x480 -r 25 -i /dev/video2 -f alsa -ac 2 -i hw:0 output.avi
The update of 5th march 2013 of ffmpeg from Reeti repository is required (older version does not recognize alsa format).
How to watch the video
vlc is preinstalled :
- run vlc
- open the video device /dev/video2
You can also use ffmpeg.
You can also install and use your favourite linux application or library. Refer to this page to be able to install an application from ubuntu repository : Update Ubuntu
How to do video computing
You can use opencv library. Here is an example that reads the video stream and detects movements : UExhibitor
How to customize video resolution and framerates
If you don't need the fakecamera, and you need some different resolutions and frame rates configurations :
- kill fakecamera process (sudo pkill fake*)
or
- suppress fakecamera from reeti launch script : edit /reetiPrograms/script/cameraInit.sh and suppress fakecamera (all lines from 7 to 15)
Once you suppressed fakecamera process, you can record (or view) one or both camera in any resolution compatible with usb2.0 flow limitation of a usb2.0 controller
Here are a few combinaisons that works :
Two camera in 640x480 @ 10 fps:
- ffmpeg -f video4linux2 -s 640x480 -r 10 -i /dev/video0 -f alsa -ac 2 -i hw:0 output0.avi
- ffmpeg -f video4linux2 -s 640x480 -r 10 -i /dev/video1 output1.avi
One camera in 640x480 @ 30 fps and one in 320x240 @ 10 fps:
- ffmpeg -f video4linux2 -s 640x480 -r 30 -i /dev/video0 -f alsa -ac 2 -i hw:0 output0.avi
- ffmpeg -f video4linux2 -s 320x240 -r 10 -i /dev/video1 output1.avi
One camera in 1280x720 @ 10 fps and one in 424x240 @ 10 fps
- ffmpeg -f video4linux2 -s 1280x720 -r 10 -i /dev/video0 -f alsa -ac 2 -i hw:0 output0.avi
- ffmpeg -f video4linux2 -s 320x240 -r 10 -i /dev/video1 output1.avi
One camera in 1280x720 @ 30 fps (in mjpeg format) and one in 424x240 @ 10 fps
- ffmpeg -f video4linux2 -vcodec mjpeg -s 1280x720 -r 30 -i /dev/video0 -f alsa -ac 2 -i hw:0 output0.avi
- ffmpeg -f video4linux2 -s 320x240 -r 10 -i /dev/video1 output1.avi
If you want to try some other combinaison, the file below gives you all formats that Reeti webcams accepts (resolution and framerates for raw images YUYV format and for mjpeg format). Note that 720p format @ 30 fps is only accessible in mjpeg format.