sparkie777
Posts: 121
Joined: Tue Nov 27, 2012 4:37 am

Re: Official V4L2 driver

Thu Jun 02, 2016 12:12 pm

it's unbelievable, auto brightness now works with my standard motion in 1920x1080!

I now also know why my previous tests some weeks ago did fail. There is a install option in my modprobe.d:

Code: Select all

install bcm2835-v4l2 /sbin/modprobe -i bcm2835-v4l2 && /usr/bin/v4l2-ctl --set-ctrl=rotate=180
I had to write this because 'bcm2835-v4l2' apparently has no module option for 'rotate=180'. And this install option prevented the 'max_video_width=2592 max_video_height=1944' to become active.

thank you again for your great support.

cheers
sparkie777

kehall
Posts: 26
Joined: Thu Dec 05, 2013 9:52 pm

Re: Official V4L2 driver

Thu Jun 02, 2016 6:10 pm

It's the longstanding issue that stills mode locks AE and AWB. V4L2 takes anything above 1280x720 (in either direction) to be a still capture.
Set the module parameters max_video_width and max_video_height to 2592 and 1944 respectively when loading bcm2835-v4l2, and it'll treat all captures as video mode.
Brilliant, that's sorted it! Thanks for the info...

Now only got the 'UNABLE TO OPEN VIDEO DEVICE' issue when width/height is 1920x1080 to sort out :)

Edited... think sorted that - each dimension has to be divisible by 16...

Keith

undertakerPi
Posts: 4
Joined: Fri Apr 01, 2016 2:32 pm

Re: Official V4L2 driver

Sun Jun 05, 2016 5:57 pm

I spend almost 2 days with searching for tools for live-stream from raspberry pi.

I am tring to use v4l2 for live streaming via udp, but I can't get it work.

Code: Select all

sudo modprobe bcm2835-v4l2
v4l2-ctl --set-fmt-video=width=320,height=240,pixelformat=1
This one is not working??

Code: Select all

avconv -f video4linux2 -r 25 -i /dev/video0 -f mpegts udp://192.168.1.5:4030
I am using VLC Player to recieve the stream.

Does anybody of you know a tool like avconv to transmit a live video via udp? (not rtmp!!) Also with really less frame rate is still ok.

Thank you

sparkie777
Posts: 121
Joined: Tue Nov 27, 2012 4:37 am

Re: Official V4L2 driver

Sun Jun 05, 2016 6:03 pm

undertakerPi wrote:I spend almost 2 days with searching for tools for live-stream from raspberry pi.
just use raspivid+mplayer and enjoy
Post

undertakerPi
Posts: 4
Joined: Fri Apr 01, 2016 2:32 pm

Re: Official V4L2 driver

Wed Jun 08, 2016 7:34 am

Thank you!!

I can not get it work with udp? :cry: Do I need to change some parameters? (I need udp for further multicasting!)

Code: Select all

raspivid -v -n -fps 30 -ih -t 0 -o - | nc -k -l -p -u 8554

Code: Select all

mplayer -fps 30 -demuxer h264es ffmpeg://udp://192.168.1.10:8554

Aydan
Posts: 700
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: Official V4L2 driver

Wed Jun 08, 2016 11:32 am

undertakerPi wrote:

Code: Select all

raspivid -v -n -fps 30 -ih -t 0 -o - | nc -k -l -p -u 8554
You have options -p and -u swapped. And as far as I understand the docs, -p and -l don't go together.

Code: Select all

raspivid -v -n -fps 30 -ih -t 0 -o - | nc -k -u -l 8554
should work

Regards
Aydan

demian_2
Posts: 9
Joined: Tue Jan 05, 2016 4:58 pm

Re: Official V4L2 driver

Tue Jul 12, 2016 3:53 pm

hi! i need some help with this. i need to get de raspi-camera resource for RPI2 in chormium 51. but the resolution is so bad.
i get this error in the rpi console:
ERROR:video_capture_device_factory_linux.cc(108)] Not implemented reached in void media::GetSupportedFormatsForV4L2BufferType(int, media::VideoCaptureFormats*)

v4l2-ctl --list-devices
mmal service 16.1 (platform:bcm2835-v4l2):
/dev/video0

v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YU12'
Name : Planar YUV 4:2:0
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 1
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 2
Type : Video Capture
Pixel Format: 'RGB3'
Name : 24-bit RGB 8-8-8
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 3
Type : Video Capture
Pixel Format: 'JPEG' (compressed)
Name : JFIF JPEG
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 4
Type : Video Capture
Pixel Format: 'H264' (compressed)
Name : H.264
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 5
Type : Video Capture
Pixel Format: 'MJPG' (compressed)
Name : Motion-JPEG
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 6
Type : Video Capture
Pixel Format: 'YVYU'
Name : YVYU 4:2:2
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 7
Type : Video Capture
Pixel Format: 'VYUY'
Name : VYUY 4:2:2
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 8
Type : Video Capture
Pixel Format: 'UYVY'
Name : UYVY 4:2:2
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 9
Type : Video Capture
Pixel Format: 'NV12'
Name : Y/CbCr 4:2:0
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 10
Type : Video Capture
Pixel Format: 'BGR3'
Name : 24-bit BGR 8-8-8
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 11
Type : Video Capture
Pixel Format: 'YV12'
Name : Planar YVU 4:2:0
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 12
Type : Video Capture
Pixel Format: 'NV21'
Name : Y/CrCb 4:2:0
Size: Stepwise 32x32 - 2592x1944 with step 2/2

Index : 13
Type : Video Capture
Pixel Format: 'BGR4'
Name : 32-bit BGRA/X 8-8-8-8
Size: Stepwise 32x32 - 2592x1944 with step 2/2

v4l2-ctl --all
Driver Info (not using libv4l2):
Driver name : bm2835 mmal
Card type : mmal service 16.1
Bus info : platform:bcm2835-v4l2
Driver version: 4.4.13
Capabilities : 0x85200005
Video Capture
Video Overlay
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x05200005
Video Capture
Video Overlay
Read/Write
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Camera 0: ok)
Format Video Capture:
Width/Height : 1024/768
Pixel Format : 'JPEG'
Field : None
Bytes per Line: 0
Size Image : 786432
Colorspace : JPEG (JFIF/ITU601)
Flags :
Format Video Overlay:
Left/Top : 150/50
Width/Height: 1024/768
Field : None
Chroma Key : 0x00000000
Global Alpha: 0xff
Clip Count : 0
Clip Bitmap : No
Framebuffer Format:
Capability : Extern Overlay
Global Alpha
Flags : Overlay Matches Capture/Output Size
Width : 1024
Height : 768
Pixel Format : 'YU12'
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 30.000 (30000/1000)
Read buffers : 1

User Controls

brightness (int) : min=0 max=100 step=1 default=50 value=50 flags=slider
contrast (int) : min=-100 max=100 step=1 default=0 value=0 flags=slider
saturation (int) : min=-100 max=100 step=1 default=0 value=0 flags=slider
red_balance (int) : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
blue_balance (int) : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
horizontal_flip (bool) : default=0 value=0
vertical_flip (bool) : default=0 value=0
power_line_frequency (menu) : min=0 max=3 default=1 value=1
sharpness (int) : min=-100 max=100 step=1 default=0 value=0 flags=slider
color_effects (menu) : min=0 max=15 default=0 value=0
rotate (int) : min=0 max=360 step=90 default=0 value=0
color_effects_cbcr (int) : min=0 max=65535 step=1 default=32896 value=32896

Codec Controls

video_bitrate_mode (menu) : min=0 max=1 default=0 value=0 flags=update
video_bitrate (int) : min=25000 max=25000000 step=25000 default=10000000 value=10000000
repeat_sequence_header (bool) : default=0 value=0
h264_i_frame_period (int) : min=0 max=2147483647 step=1 default=60 value=60
h264_level (menu) : min=0 max=11 default=11 value=11
h264_profile (menu) : min=0 max=4 default=4 value=4

Camera Controls

auto_exposure (menu) : min=0 max=3 default=0 value=0
exposure_time_absolute (int) : min=1 max=10000 step=1 default=1000 value=1000
exposure_dynamic_framerate (bool) : default=0 value=0
auto_exposure_bias (intmenu): min=0 max=24 default=12 value=12
white_balance_auto_preset (menu) : min=0 max=9 default=1 value=1
image_stabilization (bool) : default=0 value=0
iso_sensitivity (intmenu): min=0 max=4 default=0 value=0
iso_sensitivity_auto (menu) : min=0 max=1 default=1 value=1
exposure_metering_mode (menu) : min=0 max=2 default=0 value=0
scene_mode (menu) : min=0 max=13 default=0 value=0

JPEG Compression Controls

compression_quality (int) : min=1 max=100 step=1 default=30 value=30
brightness (int) : min=0 max=100 step=1 default=50 value=50 flags=slider
contrast (int) : min=-100 max=100 step=1 default=0 value=0 flags=slider
saturation (int) : min=-100 max=100 step=1 default=0 value=0 flags=slider
red_balance (int) : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
blue_balance (int) : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
horizontal_flip (bool) : default=0 value=0
vertical_flip (bool) : default=0 value=0
power_line_frequency (menu) : min=0 max=3 default=1 value=1
sharpness (int) : min=-100 max=100 step=1 default=0 value=0 flags=slider
color_effects (menu) : min=0 max=15 default=0 value=0
rotate (int) : min=0 max=360 step=90 default=0 value=0
color_effects_cbcr (int) : min=0 max=65535 step=1 default=32896 value=32896

thanks for share!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7456
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Tue Jul 12, 2016 4:28 pm

demian_2 wrote:hi! i need some help with this. i need to get de raspi-camera resource for RPI2 in chormium 51. but the resolution is so bad.
i get this error in the rpi console:
ERROR:video_capture_device_factory_linux.cc(108)] Not implemented reached in void media::GetSupportedFormatsForV4L2BufferType(int, media::VideoCaptureFormats*)
https://github.com/raspberrypi/linux/issues/1498
https://bugs.chromium.org/p/chromium/is ... ?id=616007
Chromium is doing the wrong thing and ends up asking to set a resolution of 0x0. The spec for vidioc_s_fmt requires the driver
When the application calls the VIDIOC_S_FMT ioctl with a pointer to a v4l2_format structure the driver checks and adjusts the parameters against hardware abilities.
The V4L2 driver checks the 0x0 request and amends it to the nearest that it supports, which is now 32x32. Chromium then scales that and it looks awful.

The Chromium bug has been pretty much silent since 31st May when it was raised. The simplest "fix" there is to make up a list of preferred resolutions, and then add whichever of those is supported to the list - not ideal but practical.
Alternatively you could hack the V4L2 driver to advertise a discrete list of resolutions, but then you're maintaining a custom kernel which isn't the easiest.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

redratear
Posts: 2
Joined: Fri May 06, 2016 5:40 am

Re: Official V4L2 driver

Tue Jul 19, 2016 10:49 am

please Read INSTALL file in v4l-Utils folder.

Code: Select all

sudo ./bootstrap.h
sudo ./configure
sudo make -j4
sudo make install

Delgan
Posts: 4
Joined: Fri Mar 25, 2016 2:17 pm

Re: Official V4L2 driver

Thu Jul 21, 2016 12:06 pm

Hello.

Is it possible to record a video with the new camera v2.1 at 3240x2464 resolution and in MJPG format, using v4l2?

I run the following script:

Code: Select all

sudo modprobe bcm2835-v4l2 max_video_height=2464 max_video_width=3240
v4l2-ctl -v width=3240,height=2464,pixelformat=5
V4l2-ctl --stream-mmap=3 --stream-to=/dev/null --stream-count=100
But it raises an error:

Code: Select all

VIDIOC_STREAMON: failed: Operation not permitted
I wanted to record in MJPG because it was able to reach ~13 fps with 2592x1944 resolution on camera v1.3.

How could I reproduce this with the new full-frame resolution, please?

Default format (YUV12) performs well on /dev/null, but when it comes to save images on SD (U3 class yet, so 30 MB/s theoretically) the behavior is erratic (and output file is huge):

Code: Select all

$ v4l2-ctl -p 5
Frame rate set to 5.000 fps
$ v4l2-ctl --stream-mmap=3 --stream-to=/home/pi/Desktop/test.yu12 --stream-count=50
<<<<<< 5 fps
<<<<< 4 fps
<<<<< 4 fps
<< 0 fps
<<<<<<< 6 fps
<< 0 fps
<<<<< 4 fps
<<< 0 fps
<<<<<<< 6 fps
< 0 fps
<<<<<<<

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7456
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Thu Jul 21, 2016 1:15 pm

Delgan wrote:Hello.

Is it possible to record a video with the new camera v2.1 at 3240x2464 resolution and in MJPG format, using v4l2?

I run the following script:

Code: Select all

sudo modprobe bcm2835-v4l2 max_video_height=2464 max_video_width=3240
v4l2-ctl -v width=3240,height=2464,pixelformat=5
V4l2-ctl --stream-mmap=3 --stream-to=/dev/null --stream-count=100
But it raises an error:

Code: Select all

VIDIOC_STREAMON: failed: Operation not permitted
I wanted to record in MJPG because it was able to reach ~13 fps with 2592x1944 resolution on camera v1.3.

How could I reproduce this with the new full-frame resolution, please?

Default format (YUV12) performs well on /dev/null, but when it comes to save images on SD (U3 class yet, so 30 MB/s theoretically) the behavior is erratic (and output file is huge):

Code: Select all

$ v4l2-ctl -p 5
Frame rate set to 5.000 fps
$ v4l2-ctl --stream-mmap=3 --stream-to=/home/pi/Desktop/test.yu12 --stream-count=50
<<<<<< 5 fps
<<<<< 4 fps
<<<<< 4 fps
<< 0 fps
<<<<<<< 6 fps
<< 0 fps
<<<<< 4 fps
<<< 0 fps
<<<<<<< 6 fps
< 0 fps
<<<<<<<
Interesting one that I hadn't tried before.
A couple of data points please - "uname -a" and "vcgencmd version". There was a kernel update so that V4L2 asks which camera module is installed (V1 or V2) and sets the max resolution appropriately. Looks like that was https://github.com/raspberrypi/linux/co ... 144af9ab7b on 22nd April, so your kernel needs to be from after then.

I don't get any error, but the images go hideously blocky after the first frame or two. At a guess the default V4L2 bitrate is too low so the codec ends up seriously over compressing.
If I try the equivalent raspivid line of

Code: Select all

raspivid -w 3280 -h 2464 -fps 5 -o stream.mjpg -n -cd MJPEG
I get a perfectly valid stream.

Those resolutions are going to need a lot of memory, and just checking I've found my system is set to a gpu_mem of 240MB, so that may well be the issue. Try increasing it in config.txt

YU12 will be huge as each image is 12MB is size!
Please do be careful with the MJPEG codec - there is some nasty code in the firmware side which can result in the codec stalling and being unable to shutdown. I've just had it happen with the raspivid line. I think V4L2 should be better as it passes larger buffers to the GPU to be filled. If using raspivid, increasing the 256kB at https://github.com/raspberrypi/userland ... id.c#L1703 would be very sensible.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Delgan
Posts: 4
Joined: Fri Mar 25, 2016 2:17 pm

Re: Official V4L2 driver

Thu Jul 21, 2016 3:19 pm

6by9 wrote:Interesting one that I hadn't tried before.
A couple of data points please - "uname -a" and "vcgencmd version". There was a kernel update so that V4L2 asks which camera module is installed (V1 or V2) and sets the max resolution appropriately. Looks like that was https://github.com/raspberrypi/linux/co ... 144af9ab7b on 22nd April, so your kernel needs to be from after then.

I don't get any error, but the images go hideously blocky after the first frame or two. At a guess the default V4L2 bitrate is too low so the codec ends up seriously over compressing.
If I try the equivalent raspivid line of

Code: Select all

raspivid -w 3280 -h 2464 -fps 5 -o stream.mjpg -n -cd MJPEG
I get a perfectly valid stream.

Those resolutions are going to need a lot of memory, and just checking I've found my system is set to a gpu_mem of 240MB, so that may well be the issue. Try increasing it in config.txt
uname -a
YU12 will be huge as each image is 12MB is size!
Please do be careful with the MJPEG codec - there is some nasty code in the firmware side which can result in the codec stalling and being unable to shutdown. I've just had it happen with the raspivid line. I think V4L2 should be better as it passes larger buffers to the GPU to be filled. If using raspivid, increasing the 256kB at https://github.com/raspberrypi/userland ... id.c#L1703 would be very sensible.
Thank you for your help and your quick response!

It was indeed due to gpu_mem config, after having increased it from 128 to 240, v4l2 and raspivid stopped complaining!

My system seemed updated:

Code: Select all

$ uname -a
Linux raspberrypi 4.4.13-v7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l GNU/Linux
$ vcgencmd version
Jun 20 2016 18:18:51
Copyright (c) 2012 Broadcom
version 460b39c674ef2ac89360e15331f97a2cb1388a44 (clean) (release)
I noticed too that image quality decreased after some frames, however, I was also able to fix it by modifying the order of v4l2 commands, this is very surprising.

Code: Select all

v4l2-ctl -v width=3240,height=2464,pixelformat=5
v4l2-ctl -c video_bitrate=25000000,video_bitrate_mode=0,compression_quality=100
v4l2-ctl -p 5
v4l2-ctl --stream-mmap=3 --stream-to=/home/pi/Desktop/stream_1.mjpg --stream-count=100
Total size: 14,1 MB
100th frame:
Image


Code: Select all

v4l2-ctl -p 5
v4l2-ctl -c video_bitrate=25000000,video_bitrate_mode=0,compression_quality=100
v4l2-ctl -v width=3240,height=2464,pixelformat=5
v4l2-ctl --stream-mmap=3 --stream-to=/home/pi/Desktop/stream_2.mjpg --stream-count=100
Total size: 62,1 MB
100th frame:
Image

So, it seems that video bitrate is only considered if it is set after the fps.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7456
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Thu Jul 21, 2016 3:29 pm

Delgan wrote:It was indeed due to gpu_mem config, after having increased it from 128 to 240, v4l2 and raspivid stopped complaining!
I like easy ones :D
Delgan wrote:My system seemed updated:

Code: Select all

$ uname -a
Linux raspberrypi 4.4.13-v7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l GNU/Linux
Yes, no problems there.
Delgan wrote:I noticed too that image quality decreased after some frames, however, I was also able to fix it by modifying the order of v4l2 commands, this is very surprising.

Code: Select all

v4l2-ctl -v width=3240,height=2464,pixelformat=5
v4l2-ctl -c video_bitrate=25000000,video_bitrate_mode=0,compression_quality=100
v4l2-ctl -p 5
v4l2-ctl --stream-mmap=3 --stream-to=/home/pi/Desktop/stream_1.mjpg --stream-count=100
Total size: 14,1 MB

Code: Select all

v4l2-ctl -p 5
v4l2-ctl -c video_bitrate=25000000,video_bitrate_mode=0,compression_quality=100
v4l2-ctl -v width=3240,height=2464,pixelformat=5
v4l2-ctl --stream-mmap=3 --stream-to=/home/pi/Desktop/stream_2.mjpg --stream-count=100
Total size: 62,1 MB

So, it seems that video bitrate is only considered if it is set after the fps.
I'd need to find 5 minutes to check, but I suspect it is setting width/height after bitrate that is the key. Memory says that they are both set via the same parameter, so potentially it is only setting bitrate first gets it passed in. If so then I ought to look into fixing it.
Frame rate will affect the rate control algorithm under some situations in working out how many frames to divide the rate between, but otherwise have limited effect.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Delgan
Posts: 4
Joined: Fri Mar 25, 2016 2:17 pm

Re: Official V4L2 driver

Thu Jul 21, 2016 3:53 pm

6by9 wrote:I'd need to find 5 minutes to check, but I suspect it is setting width/height after bitrate that is the key. Memory says that they are both set via the same parameter, so potentially it is only setting bitrate first gets it passed in. If so then I ought to look into fixing it.
Frame rate will affect the rate control algorithm under some situations in working out how many frames to divide the rate between, but otherwise have limited effect.
Indeed, I remember you already mentioned this issue here.

Anyway, thank you again for your help!

racer993
Posts: 60
Joined: Mon Feb 18, 2013 7:27 pm

Re: Official V4L2 driver

Sat Jul 23, 2016 3:33 pm

I have finally been able to reconstruct a color variation that appears in the v4l2 driver but not in raspistill.

Description of the issue: if I take a picture of a red object using the v4l2 driver, the picture tends to be reddish (on places where it should be white) despite using awb off. If I take the same picture using raspistill, the white stays white.

see pictures that I have attached for reference
v4l2-small.jpg
v4l2
v4l2-small.jpg (56.37 KiB) Viewed 12432 times
raspistill-small.jpg
raspistill
raspistill-small.jpg (48.55 KiB) Viewed 12432 times
I have used

Linux raspberrypi 4.4.15-v7+ #897 SMP Tue Jul 12 18:42:55 BST 2016 armv7l GNU/Linux

v4l2 settings were

Status Log:

[ 3454.126345] bcm2835-v4l2: ================= START STATUS =================
[ 3454.126370] bcm2835-v4l2: Saturation: 0
[ 3454.126386] bcm2835-v4l2: Sharpness: 0
[ 3454.126397] bcm2835-v4l2: Contrast: 15
[ 3454.126408] bcm2835-v4l2: Brightness: 50
[ 3454.126419] bcm2835-v4l2: ISO Sensitivity: 100000
[ 3454.126430] bcm2835-v4l2: ISO Sensitivity, Auto: Auto
[ 3454.126441] bcm2835-v4l2: Image Stabilization: false
[ 3454.126451] bcm2835-v4l2: Auto Exposure: Manual Mode
[ 3454.126462] bcm2835-v4l2: Exposure Time, Absolute: 10
[ 3454.126473] bcm2835-v4l2: Auto Exposure, Bias: 0
[ 3454.126483] bcm2835-v4l2: Exposure, Dynamic Framerate: false
[ 3454.126494] bcm2835-v4l2: Exposure, Metering Mode: Average
[ 3454.126504] bcm2835-v4l2: White Balance, Auto & Preset: Manual
[ 3454.126515] bcm2835-v4l2: Red Balance: 1520
[ 3454.126525] bcm2835-v4l2: Blue Balance: 1600
[ 3454.126536] bcm2835-v4l2: Color Effects: None
[ 3454.126546] bcm2835-v4l2: Color Effects, CbCr: 32896
[ 3454.126557] bcm2835-v4l2: Rotate: 0
[ 3454.126567] bcm2835-v4l2: Horizontal Flip: true
[ 3454.126578] bcm2835-v4l2: Vertical Flip: true
[ 3454.126588] bcm2835-v4l2: Video Bitrate Mode: Variable Bitrate
[ 3454.126599] bcm2835-v4l2: Video Bitrate: 10000000
[ 3454.126610] bcm2835-v4l2: Compression Quality: 30
[ 3454.126620] bcm2835-v4l2: Power Line Frequency: 50 Hz
[ 3454.126630] bcm2835-v4l2: Repeat Sequence Header: false
[ 3454.126641] bcm2835-v4l2: H264 Profile: High
[ 3454.126651] bcm2835-v4l2: H264 Level: 4
[ 3454.126661] bcm2835-v4l2: Scene Mode: None
[ 3454.126672] bcm2835-v4l2: H264 I-Frame Period: 60
[ 3454.126683] bcm2835-v4l2: ================== END STATUS ==================

comparable raspistill settings were

raspistill -v --saturation 0 --awbgains '1.52,1.6' --burst --brightness 50 --hflip --timelapse 0 --sharpness 0 --metering 'average' --vflip --height 1944 --shutter 0 --width 2592 --ISO 100 --mode 2 --timeout 1500 --output 'test%d.jpg' --nopreview --quality 100 --awb 'off' --contrast 15 --exposure 'off'

My question: Why is the picture taken with v4l2 driver reddish despite being all settings being manual?

nautilus27
Posts: 71
Joined: Fri May 22, 2015 9:38 pm

Re: Official V4L2 driver

Thu Nov 10, 2016 7:02 pm

I'm getting error with the "autoreconf -vfi" command.

Code: Select all

pi@raspberrypi:~/v4l-utils $ autoreconf -vfi
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: configure.ac: AM_GNU_GETTEXT is used, but not AM_GNU_GETTEXT_VERSION
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux'.
libtoolize: copying file `build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.ac:77: installing 'build-aux/compile'
configure.ac:88: installing 'build-aux/config.guess'
configure.ac:95: error: required file 'build-aux/config.rpath' not found
configure.ac:88: installing 'build-aux/config.sub'
configure.ac:79: installing 'build-aux/install-sh'
configure.ac:79: installing 'build-aux/missing'
contrib/cobalt-ctl/Makefile.am: installing 'build-aux/depcomp'
autoreconf: automake failed with exit status: 1

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7456
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Thu Nov 10, 2016 8:01 pm

nautilus27 wrote:I'm getting error with the "autoreconf -vfi" command.
Is there a reason why you're trying to build v4l-utils? It is already updated in the Raspbian repo.
v4l-utils has moved on in the almost 3 years since the first post on this thread, and the build runes have changed. If you do want to rebuild it, then read https://git.linuxtv.org/v4l-utils.git/about/ for instructions on building.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

nautilus27
Posts: 71
Joined: Fri May 22, 2015 9:38 pm

Re: Official V4L2 driver

Thu Nov 10, 2016 9:26 pm

6by9 wrote:
nautilus27 wrote:I'm getting error with the "autoreconf -vfi" command.
Is there a reason why you're trying to build v4l-utils? It is already updated in the Raspbian repo.
v4l-utils has moved on in the almost 3 years since the first post on this thread, and the build runes have changed. If you do want to rebuild it, then read https://git.linuxtv.org/v4l-utils.git/about/ for instructions on building.
OK, all I was trying to get my RPi v2 cam to stream video feed to my network, I found this thread and tried to apply the instuctions. What do I need then?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7456
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Thu Nov 10, 2016 10:19 pm

nautilus27 wrote:OK, all I was trying to get my RPi v2 cam to stream video feed to my network, I found this thread and tried to apply the instuctions. What do I need then?
The first line of the first post:
EDIT: the default kernel includes v4l2 driver and the latest raspbian image includes the v4l2 utilities (like v4l2-ctl) so the initial steps can be skipped. Skip forward to the modprobe line.
...
# load the module
sudo modprobe bcm2835-v4l2

# viewfinder
v4l2-ctl --overlay=1 # enable viewfinder
v4l2-ctl --overlay=0 # disable viewfinder

# record video
v4l2-ctl --set-fmt-video=width=1920,height=1088,pixelformat=4
v4l2-ctl --stream-mmap=3 --stream-count=100 --stream-to=somefile.264

# capture jpeg
v4l2-ctl --set-fmt-video=width=2592,height=1944,pixelformat=3
v4l2-ctl --stream-mmap=3 --stream-count=1 --stream-to=somefile.jpg

# set bitrate
v4l2-ctl --set-ctrl video_bitrate=10000000

# list supported formats
v4l2-ctl --list-formats
v4l2-ctl is just a test app - there's also qv4l2 as a GUI version. Did you have an intended application to stream to the network? V4L2 by itself is just a mechanism to deliver video frames.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

nautilus27
Posts: 71
Joined: Fri May 22, 2015 9:38 pm

Re: Official V4L2 driver

Thu Nov 10, 2016 10:43 pm

6by9 wrote: v4l2-ctl is just a test app - there's also qv4l2 as a GUI version. Did you have an intended application to stream to the network? V4L2 by itself is just a mechanism to deliver video frames.
I don't actually. I tried VLC with this command:

Code: Select all

raspivid -o - -t 99999 -hf -w 640 -h 360 -fps 25|cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264
the delay was too much.

jontec
Posts: 3
Joined: Sun Nov 06, 2016 9:49 pm

Re: Official V4L2 driver

Sat Nov 12, 2016 7:50 pm

I have an issue with the resolution/field of view using raspi cam and motion.
As I was not sure if it is v4l2 related or not I opened a new, more detailed thread: viewtopic.php?f=43&t=165028

I added max_video_width=2592 max_video_height=1944 to modprobe bcm2835-v4l2 and since then motion can not record stills in 2952x1944 with the full field of view of the camera anymore. Images are saved with this resolution, however, it is only showing a zoomed in (smaller field of view) version.

With

Code: Select all

v4l2-ctl --set-fmt-video=width=2592,height=1944,pixelformat=5
I can reproduce the same effect, pixelformat=3, however, saves the full field of view.

When motion was detected, I would like motion to save image stills with every two seconds at full resolution 2592x1944 (with correct AWB, exposure and field of view).

nandor65
Posts: 23
Joined: Tue Nov 22, 2016 10:34 am

Re: Official V4L2 driver

Tue Nov 22, 2016 10:52 am

hi,
Is it possible to use auto exposure mode and set a minimum fps other than fps=1? I am capturing videos during all day long and do not want to get blurred images of moving objects under low light condition. Maybe a minimum of fps=20 would be OK.
thanks.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7456
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Tue Nov 22, 2016 12:47 pm

nandor65 wrote:Is it possible to use auto exposure mode and set a minimum fps other than fps=1? I am capturing videos during all day long and do not want to get blurred images of moving objects under low light condition. Maybe a minimum of fps=20 would be OK.
Sorry, need a few more details to be able to understand what you are currently doing.
At a guess you've set V4L2_CID_EXPOSURE_AUTO_PRIORITY to 1 so that exposure time can determine the minimum frame rate. Beyond that I'm not sure how you're setting up the exposure mode. Are you using V4L2_CID_SCENE_MODE to select a scene mode? Otherwise the default max exposure (and therefore the dictated min frame rate) is 66ms / 15fps.

If using SCENE_MODE_NIGHT then the max exposure time is significantly higher.
The min frame rate when V4L2_CID_EXPOSURE_AUTO_PRIORITY is set is hard coded to 1 at https://github.com/raspberrypi/linux/bl ... ls.c#L1214, but I don't think that is really your problem. Could you clarify please?
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

nandor65
Posts: 23
Joined: Tue Nov 22, 2016 10:34 am

Re: Official V4L2 driver

Tue Nov 22, 2016 1:18 pm

6by9, thank you for your lightning fast response.

I use default values of the v4l2 driver. so scene_mode=0. exposure_auto_priority? I do not know about this control.
I set width and height and fps from OpenCV like this:
capture.set(CV_CAP_PROP_FRAME_WIDTH, camera_resolution.width);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, camera_resolution.height);
capture.set(CV_CAP_PROP_FPS, camera_fps);
where width is 1280 pixel and height is 720 pixel, so 2x2 binning is applied and max fps is 49.

I capture streams of outside vehicle traffic and try to recognise licence plates. When its daytime images of digits on the plates are sharp, when it gets darker digits get blurred. I assume because auto exposure algorithm reduces the fps. I do not mind if entire image gets darker, unless plates are human readable.

hope this helps.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7456
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Tue Nov 22, 2016 2:23 pm

nandor65 wrote:I use default values of the v4l2 driver. so scene_mode=0. exposure_auto_priority? I do not know about this control.
I set width and height and fps from OpenCV like this:
capture.set(CV_CAP_PROP_FRAME_WIDTH, camera_resolution.width);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, camera_resolution.height);
capture.set(CV_CAP_PROP_FPS, camera_fps);
where width is 1280 pixel and height is 720 pixel, so 2x2 binning is applied and max fps is 49.

I capture streams of outside vehicle traffic and try to recognise licence plates. When its daytime images of digits on the plates are sharp, when it gets darker digits get blurred. I assume because auto exposure algorithm reduces the fps. I do not mind if entire image gets darker, unless plates are human readable.
OK, so frame rate is set to be camera_fps (do check your OpenCV version number. Early versions didn't actually set this). Without setting exposure_auto_priority, AE will never change this frame rate - you will get a frame every 1/fps seconds. AE can request an exposure time that is < 1/fps seconds, but never exceed it. The exposure mode (night, sport, etc) varies other parameters such as whether to increase gain or exposure time first, and what maximum value to adopt for each.

As it gets dark then yes it will increase the exposure time (up to the defined limits) to achieve a better scene.

Motion blur on licence plate reading is a real problem. From a previous job I seem to recall them having a special 1/1000sec (1ms) exposure time, even though this was on PAL CCTV cameras where they were inherently 50Hz (and interlaced).
Your best bet is IR illumination and the Pi NoIR. All number plates in the UK (except the original white on black ones) are required to be IR reflective, therefore adding IR illumination improves readability of the plates without blinding the driver. You are highly unlikely to be able to get a readable plate from a moving vehicle at night without external illumination.
The sport exposure mode will crank up gain in preference to exposure time, but it is unlikely to give enough to make number plates readable.

For reference: V4L2_CID_EXPOSURE_AUTO_PRIORITY as documented at http://hverkuil.home.xs4all.nl/spec/uap ... trols.html
V4L2_CID_EXPOSURE_AUTO_PRIORITY (boolean)
When V4L2_CID_EXPOSURE_AUTO is set to AUTO or APERTURE_PRIORITY, this control determines if the device may dynamically vary the frame rate. By default this feature is disabled (0) and the frame rate must remain constant.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”