How to record and playback but with a specified delay

Im am currently able to record and playback a OpenCV frame in real time.
however im looking to have a specified time (lets say 20seconds) when displaying the video on screen but it not affecting the recordings.
How would i go about this?

Just make a queue that holds 20 seconds of frames.

do you have a code snipet i can have to be able to reference from?