I'm hoping to get some assistance with this. So just a little background, I'm using a Pi Zero with the Pi Camera module (5mp) as an alternative to an action cam (like GoPro). I don't like the cropped look for 1080p so I've been playing around with Modes 4 and 5 for the higher FOV (and 720p is good enough for me) So I've wired a switch to one of the GPIO and I'm using Python scripts to start and stop recording since the time of each recording is always going to be different. The first script is just a listener script that is run at boot and if the switch is turned to the "On" position it runs the main Python script which is where the recording code takes place. That script will record and then stop recording and close the PiCamera object when the switch is put into the "Off" position.
Everything is working as intended and it's been loads of fun thus far, however, when I go back and watch the recorded videos there are so many dropped frames it makes for quite an un-enjoyable experience. Mind you the camera is moving quite fast (attached to 5-inch race/freestyle Quad-copter) and I understand the limitation of 49fps in 720p (mode 5), but even at 25fps the frame drop is too much. Now I'm sure the shock of the quick movements don't help, but even on the shelf while testing I can't seem to get a solid fps with out dropping frames. I'll have to edit this post with the actual script when I get home, but while using PiCamera the only settings I'm adjusting are Mode, Resolution, and FPS, everything else is default. Before I go too crazy, is the Pi Zero capable of actually getting a solid 30fps on 720p while recording without dropping frames? This Pi is not used for anything other than this application (aside from a Samba share for Windows PC to copy the video files to, and VNC for when I'm too lazy to hook up KVM)
I've tried resetting ribbon cable several times, updates and upgrades, playing with bitrates and levels and all types of settings, GPU split from 128 all the way up to 384 (currently set back to 256, CPU seems happier with 256 rather than 128)
My next thought is to try fresh install of Raspian and disable everything but the camera? Mind you, I'm running the OS on a Class 10 (16Gb) SD.
I also have a Pi Zero W, but decided to go with my regular Pi Zero because I didn't need the wifi for this application, is there a difference with performance with the recording video between the two?
Thanks in advance!
First is the listener script:
Code: Select all
import RPi.GPIO as GPIO from time import sleep from os import system pin = 24 while True: GPIO.setmode(GPIO.BCM) GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) sleep(2) while True: sleep(0.3) if (GPIO.input(pin) == GPIO.HIGH): break GPIO.cleanup() system("python /home/pi/run.py") sleep(5)
Code: Select all
from datetime import datetime from os import path from os import system d = datetime.now() dfilex1 = d.strftime("%m"+"%d"+"%Y"+"_") dfilex2 = d.strftime("%H") dfilex3 = d.strftime("%M") tname = '/home/pi/fpv/'+dfilex1+dfilex2+dfilex3+'.h264' if path.isfile(tname): id2 = int(dfilex2) id3 = int(dfilex3) while True: id3 = id3 + 1 if (id3 > 59): id3 = 00 id2 = id2 + 1 t2name = '/home/pi/fpv/'+dfilex1+str("%02d" % (id2))+str("%02d" % (id3))+'.h264' if path.isfile(t2name): t2name = None continue else: fname = t2name t2name = None id2 = None id3 = None break else: fname = tname tname = None dfilex1 = None dfilex2 = None dfilex3 = None d = None import RPi.GPIO as GPIO from time import sleep pin = 24 GPIO.setmode(GPIO.BCM) GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) sleep(1) from picamera import PiCamera try: camera = PiCamera() camera.sensor_mode = 4 camera.framerate = 30 camera.rotation = 270 camera.resolution = 1280,720 sleep(3) camera.start_recording(fname) while True: if GPIO.input(pin) == 0: camera.wait_recording(0.5) camera.stop_recording() sleep(1) break else: camera.wait_recording(0.5) finally: GPIO.cleanup() camera.close()