How to make a video using raspberry pi camera without it crashing

I have written a script using python (flask) which runs on local service

the scripts purpose is to create a video and store on my raspberry pi desktop which works

but after this video is created while a preview is shown, the camera crashes.

This is what I am trying below

import os
import os.path
from flask import Flask
from picamera import PiCamera
from time import sleep
import sys

app = Flask(__name__)

@app.route('/')
def index():

    camera = PiCamera()
    

    camera.start_preview()
    camera.start_recording('/home/pi/Desktop/play.h264')
    sleep(15)

   
    camera.stop_recording()
    camera.stop_preview()

  

if __name__ == '__main__':
    app.run(debug=True, port=8000, host='0.0.0.0')

please see screenshot of error below

preview of crash error returned

Please help



Read more here: https://stackoverflow.com/questions/68484753/how-to-make-a-video-using-raspberry-pi-camera-without-it-crashing

Content Attribution

This content was originally published by famakin taiwo at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: