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
Frame rate adjustment #279
Conversation
Interesting stuff - I've missed so much on the forums lately! Some notes on the PR:
I'll leave this open for now because I sadly don't have the time to play with it right now - once I've got the new layer finished and pushed, I'll see if we can get this into the 1.11 release. |
Thanks for the feedback. I updated it to use Fraction, and drastically simplified the example. I'm happy to contribute to compoundpi, ha didn't know it existed; will have a look. |
This works well for the v1 camera module. Just tested it on v2 camera, and the video frame rate parameter does seem to work as expected. Need to dig a bit into why. |
To be honest if it only works on v1 that'd still be a good enough reason to include it (after all, it's the vast majority of current users :). The new layer is taking a bit longer than expected (I've only just got back to a point where both capture and recording fully work, but unencoded RGB/BGR captures are currently broken) - but I'll try and take a look at converting and including this if I get time at the weekend. |
Ok, so turns out that limiting the denominator is necessary for the v2 board. Perhaps those rationales are really 16 bit, rather than 32 bit? Anyhow, tested on v1 and v2. Thanks for the update. If you need testers/reviewers for your big change; happy to try it out :) |
# Need to limit the denominator, to something reasonable, I | ||
# assume due to overflow. Can't find documentation on this, | ||
# but 512 seems to work OK. | ||
value = value.limit_denominator(512) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=48238&start=75#p908303, it's in 1/256th steps at the lowest level. There's going to be no gain in working in smaller steps than that.
Right, time to deal with this. I'm going to close this PR, but don't despair - the functionality will be going into 1.11 - just in a slightly different (easier) form. The basis for this is some experimenting with the VIDEO_FRAME_RATE parameter, and some offline discussions with @6by9. The upshot is as follows:
I must admit I didn't realize the camera could just change framerate on the fly like this. So, for 1.11 what I'm going to do is re-write the What does this mean for synchronization via minor framerate adjustments? Quite simply: no need for another parameter on PiCamera - just feed fractional values to the framerate property and the camera will be adjusted "live". To @ethanrublee: apologies I couldn't merge this as it was - but many thanks for bringing the functionality to my attention! It's definitely worth including, and it will be there (in a slightly different form) in 1.11. |
Sweet, no I don't mind. I've been using this now for a few weeks, and its been useful. Glad to get the functionality in somehow. I'll test 1.11 when you have it ready :) |
Hmm, looks like I'm going to have to redo this. I've been following the >100fps discussion on the 8MP Camera thread and there's several important points to take from ethanol100's patch. Firstly, a portion of the camera configuration (num_preview_video_frames) now derives from framerate, so the framerate property needs to disable and re-enable the camera to set that. That in turn means framerate adjustment ought to be a separate property that doesn't modify the camera config and simply adjusts the framerate by minimal amounts (probably best to make it a delta to avoid confusion; i.e. default it to 0 so it doesn't need to shift value every time framerate changes). |
As per direct email, please ignore num_preview_video_frames changing with framerate. Use 10 frames and have done with it. The one side I hadn't considered was memory requirements though. 10 frames at 1080P is fairly chunky at about 40MB. Perhaps further testing is required to see how many buffers are really needed to avoid starving the pipe. |
Yeah - I had a feeling memory might be an issue. I've been testing with 10, and (without tweaking gpu_mem) I can't set the maximum resolution on a V1 camera, let alone a V2 (I suspect this is partially down to picamera always using a full preview resolution too). For now, I'll go with the variable level - it also keeps picamera closer to rapsivid, which is always nice. I'll probably have to re-visit the full preview resolution decision at some point though (it already causes issues with stereoscopic setups). |
Revert framerate to disabling / enabling the camera, and add a separate framerate_delta property to handle live adjustments to the framerate.
Happy to amend, add tests, or take feedback.