# First frames of video from Rasp Pi camera have a high exposure

When I record video using the v1 of the Rasp Pi Noir camera the first few frames/second have a very high exposure (very bright) and then it settles down to a reasonable exposure setting. Because the videos are taken throughout the day I think I need to rely on auto exposure. I'm looking for a way to avoid having these very bright/washed out frames at the beginning. The command I'm using to capture the video is

raspivid -o test.h264 -t 200000 -fps 2 -w 1280 -h 720


I use MP4Box to make the video into an MP4 file. If it isn't possible to avoid capturing these washed-out frames is there a way to trim them out after capture?

Hi the initial washed out frames are the camera judging the exposure. The Pi camera modules automatically manage the exposure.

The camera must produce preview frames even if these aren't required for display, as they're used for calculating exposure and white balance settings

Pi Camera Modules

In terms of the removing them there will be a way to do it automatically I'm sure but I wouldn't know where to start I'm afraid. The only thing I can suggest would be removing them in a video editor.

• Yes, I understand judging the exposure. To be clear I need a programmatic way to remove those frames if I can't avoid them. For my project running a video editor with a GUI won't help. – Ron Feb 10 at 21:36
• How about using some python code and the PiCamera library. Use start_preview a few seconds before start_recording may avoid the issue. – CoderMike Feb 10 at 22:03
• Thanks for the suggestion on the library. It was easy to create something to try to work around this issue. Unfortunately today there is a heavy overcast and rain so I can't be sure it is working. Once there is a sunny day if it looks good I'll post a code sample. – Ron Feb 11 at 18:02

Thanks to CoderMike's suggestion to use the PiCamera library I've come up with what seems to be a working solution. My first few attempts didn't work (e.g. doing a sleep right before calling start_recording). The solution below records two videos. The first, trash.h264, is a throw away file that captures a few seconds at 15 fps. The second video, test.h264, is the one I want. Testing on a bright day today shows that trash.h264 is blown out but test.h264 is properly exposed.

from time import sleep
import picamera

camera = picamera.PiCamera()
camera.resolution = (1280, 720)
camera.framerate = 15
# First few seconds are blown out as auto-exposure kicks in, so record a dummy first.
camera.start_recording('trash.h264')
camera.wait_recording(5)
camera.stop_recording()

camera.framerate = 2
camera.start_recording('test.h264')
camera.wait_recording(140)
camera.stop_recording()