waveform80 / picamera

A pure Python interface to the Raspberry Pi camera module
https://picamera.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.57k stars 355 forks source link

Video recording duration #647

Open sgarzo10 opened 4 years ago

sgarzo10 commented 4 years ago

Hi,

if i register a video with this code:

from picamera import PiCamera

camera = PiCamera(resolution=(3280, 2464), framerate=30) camera.start_recording('video.h264', format='h264', quality=10, resize=(1920, 1080)) camera.wait_recording(10) camera.stop_recording() camera.close()

the video recorded duration is only 2 or 3 second.

I have test more combination like set resolution to (1920, 1080) and remove resize in method start_recording but the result is the same.

If i register a video with this command:

sudo raspivid -t 10000 -o video.h264

the video recorded duration is 10 second.

Can anyone help me?

Where am I doing wrong?

Thanks.

6by9 commented 4 years ago

The sensor can't produe 8MPix @ 30fps - see https://picamera.readthedocs.io/en/latest/fov.html#sensor-modes It'll be producing probably 1920x1080 @ 30fps and then cropping and upscaling in the ISP.

The ISP will only produce around 120MPix/s (either in or out) so whilst it's trying to take in 30fps, to produce 8MPix output images it'll be dropping frames to produce a maximum of 15fps.

Resize is then a fairly expensive operation, so I suspect you'll be maxing out the processing on that resize too.

H264 you normally set the bitrate rather than the quality. Quality goes and fixes the Qp (quantisation parameter) and can do strange things.