Python Forum
Video recording with Raspberry Pi - What´s wrong with my python code?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Video recording with Raspberry Pi - What´s wrong with my python code?
#1
Dear everyone,

for an ecological study I recorded insects in front of a nesting aid with a Raspberry Pi. I wrote a simple python code to do this which I looped via a crontab (at least I thought it was simple). After I rewatched my videos, I noticed that the recordings did not stop after one hour (as I intended) but recorded on, until my energy saving tool (a wittyPi) powered the Raspberry Pi down (and I wondered why a couple of USB-sticks kicked the bucket LOL) . Although I got my videos, it still bugs me - what is wrong with my code? Maybe anyone knows?

import datetime
import time
date = datetime.datetime.now().strftime("%m_%d_%Y_%H_%M_%S")
import picamera
camera = picamera.PiCamera()

camera.annotate_background = picamera.Color('black') #this determines the background color
camera.annotate_text = date #places timestamp on first frame of video
camera.start_recording("/media/pi/SD_02/"+ "Plotxx_" + date + ".h264")
start = datetime.datetime.now()
while (datetime.datetime.now() - start).seconds < (3600):#this indicates to continue filming until you reach the maximize time for a given recording segment
    camera.annotate_text = datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')
    camera.wait_recording(0.2)
camera.wait_recording(3600)
camera.stop_recording() 
Reply


Messages In This Thread
Video recording with Raspberry Pi - What´s wrong with my python code? - by Montezuma1502 - Feb-24-2023, 03:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I have a code which is very simple but still I cannot detect what's wrong with it max22 1 515 Nov-07-2023, 04:32 PM
Last Post: snippsat
  Something wrong with my code FabianPruitt 5 893 Jul-03-2023, 10:55 PM
Last Post: Pedroski55
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,626 Mar-27-2023, 07:38 AM
Last Post: buran
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,879 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,646 Nov-05-2022, 11:33 AM
Last Post: Mavoz
Smile How we can prevent screen recording murad_ali 3 1,877 Jul-29-2022, 10:29 AM
Last Post: DeaD_EyE
  How to output Python in Spout or any other video sharing network? buzzdarkyear 4 2,205 Jan-11-2022, 11:37 AM
Last Post: buzzdarkyear
  Wrong code in Python exercise MaartenRo 2 1,559 Jan-01-2022, 04:12 PM
Last Post: MaartenRo
  The code I have written removes the desired number of rows, but wrong rows Jdesi1983 0 1,650 Dec-08-2021, 04:42 AM
Last Post: Jdesi1983
  How to decrease latency while recording streaming video. unicorn2019 0 1,280 Nov-15-2021, 02:12 PM
Last Post: unicorn2019

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020