i made a little tweek in ofVideoGrabber.cpp to inhibate the selection of the format with higher framerate
`if (desired_framerate == -1){
// choose faster
if(new_framerate > curr_framerate) {
ofLogVerbose(“ofGstVideoGrabber”) << “add_video_format(): higher framerate not replacing existing format”;
**//**webcam_device.video_formats[i] = video_format;
with this mod the selected format don’t change anymore, and it works (but i have to force videoGrabber to OF_PIXEL_I420, OF_PIXEL_NATIVE does not work and produce a wrong pipeline)
here are the logs from lpmt starting with 2 v4l2loopbacks streaming
~/mapping/dev/lpmt$ bin/lpmt_debug
using config file config.xml
[verbose] ofxKinect: context inited
[warning] ofxKinect: no available devices found
[verbose] ofGstUtils: gstreamer inited
[notice ] ofGstVideoGrabber: Probing devices with udev…
[notice ] ofGstVideoGrabber: Found device 13d3:5711, getting capabilities…
[notice ] ofGstVideoGrabber: detected v4l2 device: USB 2.0 UVC VGA WebCam
[notice ] ofGstVideoGrabber: driver: uvcvideo, version: 199947
[notice ] ofGstVideoGrabber: Capabilities: 0x84000001
[notice ] ofGstVideoGrabber: Found device :, getting capabilities…
[notice ] ofGstVideoGrabber: detected v4l2 device: Dummy video device (0x0000)
[notice ] ofGstVideoGrabber: driver: v4l2 loopback, version: 2048
[notice ] ofGstVideoGrabber: Capabilities: 0x05000001
[notice ] ofGstVideoGrabber: Found device :, getting capabilities…
[notice ] ofGstVideoGrabber: detected v4l2 device: Dummy video device (0x0001)
[notice ] ofGstVideoGrabber: driver: v4l2 loopback, version: 2048
[notice ] ofGstVideoGrabber: Capabilities: 0x05000001
[notice ] ofGstVideoGrabber: Found device :, getting capabilities…
[notice ] ofGstVideoGrabber: detected v4l2 device: Dummy video device (0x0002)
[notice ] ofGstVideoGrabber: driver: v4l2 loopback, version: 2048
[notice ] ofGstVideoGrabber: Capabilities: 0x05000002
[notice ] device /dev/video3 seems to not have the capture capability, (radio tuner?)
[notice ] removing it from device list
[verbose] Device: Dummy video device (0x0000) (/dev/video1)
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw I4201024x768 videoformat: 2 framerates:
[verbose] 30/1
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw YV121024x768 videoformat: 3 framerates:
[verbose] ofGstVideoGrabber: get_supported_framerates(): from 0/1 to 100/1
[verbose] ofGstVideoGrabber: add_video_format(): higher framerate not replacing existing format
[verbose] ofGstVideoGrabber: add_video_format(): already added, skipping
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw BGR1024x768 videoformat: 16 framerates:
[verbose] ofGstVideoGrabber: get_supported_framerates(): from 0/1 to 100/1
[verbose] ofGstVideoGrabber: add_video_format(): higher framerate not replacing existing format
[verbose] ofGstVideoGrabber: add_video_format(): already added, skipping
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw RGB1024x768 videoformat: 15 framerates:
[verbose] ofGstVideoGrabber: get_supported_framerates(): from 0/1 to 100/1
[verbose] ofGstVideoGrabber: add_video_format(): higher framerate not replacing existing format
[verbose] ofGstVideoGrabber: add_video_format(): already added, skipping
[notice ] ofGstVideoGrabber: initGrabber(): selected device: Dummy video device (0x0000)
[notice ] ofGstVideoGrabber: initGrabber(): selected format: 1024x768 video/x-raw I420 framerate: 30/1
[notice ] ofGstUtils: setPipelineWithSink(): gstreamer pipeline: v4l2src name=video_source device=/dev/video1 ! video/x-raw,format=I420,width=1024,height=768,framerate=30/1 ! videoscale method=2 ! appsink name=ofappsink caps=“video/x-raw, format=I420, width=1024, height=748”
[verbose] ofGstUtils: startPipeline(): attaching callbacks
camera with id 1 asked for 1024 by 748 - actual size is 1024 by 748
[notice ] ofGstVideoGrabber: Probing devices with udev…
[notice ] ofGstVideoGrabber: Found device 13d3:5711, getting capabilities…
[notice ] ofGstVideoGrabber: detected v4l2 device: USB 2.0 UVC VGA WebCam
[notice ] ofGstVideoGrabber: driver: uvcvideo, version: 199947
[notice ] ofGstVideoGrabber: Capabilities: 0x84000001
[notice ] ofGstVideoGrabber: Found device :, getting capabilities…
[notice ] ofGstVideoGrabber: detected v4l2 device: Dummy video device (0x0000)
[notice ] ofGstVideoGrabber: driver: v4l2 loopback, version: 2048
[notice ] ofGstVideoGrabber: Capabilities: 0x05000001
[notice ] ofGstVideoGrabber: Found device :, getting capabilities…
[notice ] ofGstVideoGrabber: detected v4l2 device: Dummy video device (0x0001)
[notice ] ofGstVideoGrabber: driver: v4l2 loopback, version: 2048
[notice ] ofGstVideoGrabber: Capabilities: 0x05000001
[notice ] ofGstVideoGrabber: Found device :, getting capabilities…
[notice ] ofGstVideoGrabber: detected v4l2 device: Dummy video device (0x0002)
[notice ] ofGstVideoGrabber: driver: v4l2 loopback, version: 2048
[notice ] ofGstVideoGrabber: Capabilities: 0x05000002
[notice ] device /dev/video3 seems to not have the capture capability, (radio tuner?)
[notice ] removing it from device list
[verbose] Device: Dummy video device (0x0001) (/dev/video2)
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw I4201024x768 videoformat: 2 framerates:
[verbose] 30/1
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw YV121024x768 videoformat: 3 framerates:
[verbose] ofGstVideoGrabber: get_supported_framerates(): from 0/1 to 100/1
[verbose] ofGstVideoGrabber: add_video_format(): higher framerate not replacing existing format
[verbose] ofGstVideoGrabber: add_video_format(): already added, skipping
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw BGR1024x768 videoformat: 16 framerates:
[verbose] ofGstVideoGrabber: get_supported_framerates(): from 0/1 to 100/1
[verbose] ofGstVideoGrabber: add_video_format(): higher framerate not replacing existing format
[verbose] ofGstVideoGrabber: add_video_format(): already added, skipping
[verbose] ofGstVideoGrabber: add_video_format(): video/x-raw RGB1024x768 videoformat: 15 framerates:
[verbose] ofGstVideoGrabber: get_supported_framerates(): from 0/1 to 100/1
[verbose] ofGstVideoGrabber: add_video_format(): higher framerate not replacing existing format
[verbose] ofGstVideoGrabber: add_video_format(): already added, skipping
[notice ] ofGstVideoGrabber: initGrabber(): selected device: Dummy video device (0x0001)
[notice ] ofGstVideoGrabber: initGrabber(): selected format: 1024x768 video/x-raw I420 framerate: 30/1
[notice ] ofGstUtils: setPipelineWithSink(): gstreamer pipeline: v4l2src name=video_source device=/dev/video2 ! video/x-raw,format=I420,width=1024,height=768,framerate=30/1 ! videoscale method=2 ! appsink name=ofappsink caps=“video/x-raw, format=I420, width=1024, height=748”
[verbose] ofGstUtils: startPipeline(): attaching callbacks
camera with id 2 asked for 1024 by 748 - actual size is 1024 by 748
listening for OSC messages on port: 12345
i can see a great differnces in cpu usage from using yuv format without rgb compression (hard to say but i think cpu usage is almost dived by two).
But there is still a little problem, the stream i’m getting in OF is black and white. It seems OF doesn’t care about the U and V planes.
Anyway, there is still quite a few problems to get yuv stream to OF through a v4l2loopback
-the detection of the format and framerate through a v4l2loopback is quite strange, the algorithm who choose which format is better by looking which one get the better framerate is causing issue if the framerate value is not correctly captures.
-i have to set pixel format to make the video grabber work, so if it’s supposed to detect the format, it seems it doesn’t work through a v4l2loopback
- the stream gets black and white, no color.