I am just interested in raw uncompressed data and not particularly raw bayer data, I assumed a *.yuv format video sequence generated using the simple python code :
#!/usr/bin/python import time from picamera import PiCamera camera = PiCamera() camera.resolution = (640, 480) camera.framerate = 30 camera.iso = 400 camera.shutter_speed = 3000 ext = 'yuv' fileName = '/home/pi/video/stream_' + time.strftime('%d-%m-%Y_%H-%M-%S') + "." + ext camera.start_recording(fileName, ext) camera.wait_recording(30) camera.stop_recording() camera.close()
should have been good enough. But for some reason the generated recording had missing frames and the quality did not really impress me. The missing frame problem seems to be solved for a lower resolution i.e., "320x240" or a lower frame rate i.e., 5 fps at "640x480" resolution. The specifications are as follows :
- Raspberry Pi 2 model B
- CPU freq. overclocked to 1 GHz
- GPU memory 128
- 32 GB ultra class 3 SD-Card
The problem persists even if I caputure images using the following code:
#!/usr/bin/python import io import time import picamera import cv2 frames = 1800 with picamera.PiCamera() as camera: camera.resolustion = (640, 480) camera.framerate = 30 time.sleep(2) camera.shutter_speed = 2500 start = time.time() camera.capture_sequence(['images%04d.yuv'%i for i in range(frames)], 'yuv' , use_video_port=True) finish = time.time() print('Captured %d frames at %.2ffps' % ( frames, frames / (finish - start)))
and convert it to a video stream using FFmpeg as:
ffmpeg -f image2 -r 30 -s 640x480 -pix_fmt yuv420p -vcodec rawvideo -i images%04d.yuv -vcodec ffvhuff video.avi
I can't seem to understand the reason behind the missing frames, I assume it has something to do with the writing speed, the video buffer, memory at most. I would really appreciate if someone can point me in the right direction.
Note : The video recording seems to work fine for .h264 format. Which is awkward since it should be slower compared to raw formats due to the encoding step.