Code: Select all
import io import picamera import time class PtsOutput(object): def __init__(self, camera, video_filename, pts_filename): self.camera = camera self.video_output = io.open(video_filename, 'wb') self.pts_output = io.open(pts_filename, 'w') self.start_time = None def write(self, buf): self.video_output.write(buf) if self.camera.frame.complete and self.camera.frame.timestamp: if self.start_time is None: self.start_time = self.camera.frame.timestamp self.pts_output.write('# timecode format v2\n') self.pts_output.write('%f\n' % ((self.camera.frame.timestamp - self.start_time) / 1000.0)) def flush(self): self.video_output.flush() self.pts_output.flush() def close(self): self.video_output.close() self.pts_output.close() with picamera.PiCamera() as camera: camera.resolution = (320,240) camera.framerate = 30 camera.start_recording( PtsOutput(camera, 'test_30fps.yuv', 'pts.txt'), format='yuv' ) camera.start_preview() camera.wait_recording(60) camera.stop_recording()
1. What is the exact definition of a Presentation time stamp.? how accurate are these time stamps ?
2. I calculate the inter-frame duration (time duration between any two consecutive frames using presentation time stamps.) The precision is too good. 99.9% frames have same inter-frame duration. Is it expected?
3. 0.1% frames have a different inter-frame duration than the most common value. Does this mean that camera's frame rate decreases/increases ? Why this happens? And in this case also do the presentation time stamps remain consistent, or they lose their accuracy ?
Thanks in Advance.