I need to take a video under low light conditions using a NoIR Pi camera, so I followed the suggestions given in this post. But I still get completely black frames. I have attached the code here.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
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') #For recording timestamps of the frames
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 = (640,480)
time.sleep(30)
camera.exposure_mode = 'off'
camera.framerate = 30
camera.start_recording(PtsOutput(camera, '640480_30fps.h264','yuv_pts_640480_30fps.txt'), format='h264')
camera.start_preview()
camera.wait_recording(60)
camera.stop_recording()
What am I doing wrong?