Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem setting bitrate through web interface #30

Closed
lastbestmatt opened this issue Feb 4, 2017 · 5 comments
Closed

Problem setting bitrate through web interface #30

lastbestmatt opened this issue Feb 4, 2017 · 5 comments

Comments

@lastbestmatt
Copy link

While using rpos, I noticed that when setting video_bitrate through the web interface, the value is not preserved. The value always reads '0' in the v4l2ctl.json settings file. I tracked this down to what I think is a RegExp bug in v4l2ctl.ts

In the ReadControls() function, we take the control name and append the variable regexPart to create a RegExp that is matched against the output of v4l2-ctl -l command.

The problem shows when two different controls start the same way: in this case video_bitrate_mode and video_bitrate. The regex will match video_bitrate_mode for both controls. So, when you attempt to set video_bitrate, it takes affect and even gets written to file correctly. But anytime the file is read, the value of video_bitrate_mode will be captured for both controls.

To fix, you could change

var regexPart = ".*value=([0-9]*)";

to

var regexPart = "\\s.*value=([0-9]*)";

This will require whitespace after the control name, which will limit the RegExp to only match the correct control.

@RogerHardiman
Copy link
Collaborator

Thanks for the bug report.
I had seen this problem but never had the time to investigate so thank you for the fix.

Will we always have a whitespace after the name in v4l2-ctl?
Is that part of the formatting?

@lastbestmatt
Copy link
Author

It's a good question, I'm not sure. I also considered \b for a word break, which would catch both a whitespace or a colon. However, this wouldn't allow for names with a hyphen (-) in them if those exist (it would allow underscores).

Just remember to escape the slash in the string, or you'll really confuse yourself.

@RogerHardiman
Copy link
Collaborator

I am back in the office now and checked my RPi.
The original regex is fine.
I have a fork of rpos (with extra things like PTZ support and Aux/Relay support) and will add it into my fork too.

@lastbestmatt
Copy link
Author

For the record, we should note that the sense of auto_exposure is backwards in these settings. A value of 0, or unchecked, means auto exposure is on. A value of 1 or checked means manual exposure. Not sure the easiest way to note this in the interface, but I suppose you could change it to a menu/dropdown type where "on" = 0 and "off" = 1.

@RogerHardiman
Copy link
Collaborator

This bug has been fixed in RPOS now. (I've pulled in the Pull Request from my fork).
Thanks again for the bug report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants