是否可以将变量内容复制到给定位置( stream.copy_to('motion.h264') ),而不是将其保存在变量中以进行进一步处理。我想这样做的原因是,一旦收集了视频缓冲区,就能够降低视频分辨率。
提前致谢!
import io
import random
import picamera
def motion_detected():
# Randomly return True (like a fake motion detection routine)
return random.randint(0, 10) == 0
camera = picamera.PiCamera()
stream = picamera.PiCameraCircularIO(camera, seconds=20)
camera.start_recording(stream, format='h264')
try:
while True:
camera.wait_recording(1)
if motion_detected():
# Keep recording for 10 seconds and only then write the
# stream to disk
camera.wait_recording(10)
stream.copy_to('motion.h264')
finally:
camera.stop_recording()