Problem with start_recording() / stop_recording() - Raspberry Pi Forums


hi, i'm new in forum , i've problem video recording using picamera. looking answer on google , documentation haven't found similar problem.

code:

code: select all

import sys import socket import picamera import io import time import thread import gc  camera = none photo = none flag = 0 ind = 0 def main():     try:         thread.start_new_thread(make_vid,())     except:         print 'thread error.'  def make_vid():     print 'make'      while 1:         record()          def record():     print str(ind)     global ind     ind += 1      try:         global camera         camera = picamera.picamera()         camera.resolution = (640,480)         camera.framerate = 90              camera.start_preview()              stream = picamera.picameracirculario(camera,seconds=1)         print '     make stream'                 camera.start_recording(stream, format='h264',quality=10)         print '     start recording'         camera.wait_recording(0.1)         print '     wait recording'          print '     before stop recording'         camera.stop_recording()         print '     after stop recording'     finally:         camera.stop_preview()         print '     stop preview'         camera.close()         print '     close camera'          stream.truncate()     print '     stream truncate'     stream.seek(0)     print '     stream seek'      if(flag == 0):         global photo         photo = stream.getvalue()         print '     stream photo'              stream.close()     print '     stream close'     stream = none     print '     stream none'          time.sleep(0.1) 
try record 0.1s videos in while loop. program stucks between "before stop recording" , "after stop recording" print. thought it's memory leaks problem create , close in every loop still doesn't works. , doesn't throws errors.
wrong? i'll grateful help.

i ran similar problem. seems

code: select all

camera = picamera.picamera()
can called once. you're calling in while loop, problem. should call 'camera = picamera.picamera()' outside of loop , pass camera parameter function in loop.


raspberrypi



Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62