guach
Posts: 5
Joined: Sat Mar 19, 2016 9:26 pm

raspivid circular buffer documentation?

Thu Nov 16, 2017 5:28 pm

I try to use the raspivid circular buffer but I can not find any documentation of:
The size of the ring buffer. Is it modifiable? (by time, by frames, by memory occupation? ....)
In the case of using the -s option
How can the signal be sent from a python script?
What kind of signal does raspivid support?

Since I want to launch raspivid as a subprocess in the background to continue obtaining data from accelerometers, I guess I can not use picamera.
I am absolutely lost without access to documentation.
Please help

ethanol100
Posts: 539
Joined: Wed Oct 02, 2013 12:28 pm

Re: raspivid circular buffer documentation?

Thu Nov 16, 2017 6:18 pm

Sorry, I don't think there is a documention for the circular buffer.

The ring buffer size is calculated from the timeout and bit rate value:

Code: Select all

int count=state.bitrate * (state.timeoute  / 1000) / 8;

This mean we allocated as many bytes as would be needed at the given bitrate to save timeout seconds.

This will not give timeout seconds video, as we need to have a valid I frame to start with. The I frames are only each 60(?) frame, this can be set too. If you are unlucky you will have 59 frames at the beginning which will need to be skiped.

The signal to the program can be keypress or signal. If it is set to signal you can send the program a "USR1" kill signal to trigger it.

I'm not using python, but I guess you can use something like "os.kill(pid, signal.SIGUSR1)))".

I would recommend to use the picamera python library, which has an excellent documentation.

guach
Posts: 5
Joined: Sat Mar 19, 2016 9:26 pm

Re: raspivid circular buffer documentation?

Fri Nov 17, 2017 9:15 am

Thank you very much for the response, simple and effective.
The size of the ring buffer is not exact but sufficient for my application. (I request 50 sec. and I get 62 sec.) ;)
The USR1 signal works perfectly from a python script. :P
I will return to study the possible use of picamera, although I think I have read somewhere that picam can not be launched as a subprocess and continue with the application, for example continue reading the accelerometers while recording video.

Thanks again for putting some light on these cryptic -c raspivid options :D

syadnom
Posts: 15
Joined: Tue Jan 31, 2012 2:43 am

Re: raspivid circular buffer documentation?

Sun Jul 15, 2018 6:44 pm

If raspivid is set with -t 0 (ie, run continously) then how is the buffer calculated? I'm wanting to get about 10 seconds in the buffer and use -s to trigger recording.

ethanol100
Posts: 539
Joined: Wed Oct 02, 2013 12:28 pm

Re: raspivid circular buffer documentation?

Mon Jul 16, 2018 9:48 am

It will fail with an error: "Error, circular buffer size is based on timeout must be greater than zero".
When selecting the circular buffer mode, the timeout value will not be used to shutdown raspivid after this duration, it will basically run like -t 0.

Code: Select all

raspivid -t 10000 -c -s -o out.h264
This will exactly do, what you want, wait forever until triggered and save the last ~10s when triggered.

This will not enable you to trigger a second time. The current mode is only to trigger once, then quit.

syadnom
Posts: 15
Joined: Tue Jan 31, 2012 2:43 am

Re: raspivid circular buffer documentation?

Mon Jul 16, 2018 1:48 pm

ok, so I'll need to run in circular mode with a long time-out, trigger when I want recording and then end and restart the process to be ready for the next recording yes?

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 6 guests