himani18
Posts: 44
Joined: Fri Feb 19, 2016 4:52 pm

how to increase video duration of on going recording

Fri Apr 29, 2016 2:45 pm

hey..
i am using the below code...
problem with this is that I can record video only upto 3 seconds...
so can anyone tell me how to increase the duration of on going recording...
suppose i want to set predefined 20sec of continous recording...

Code: Select all

import RPi.GPIO as GPIO
import time
import picamera
import datetime

def file_name():
        return datetime.datetime.now().strftime("/home/pi/programs/test/video/%Y-%m-%d_%H.%M.%S.h264")   

 sensor=7
GPIO.setmode(GPIO.BOARD)
GPIO.setup(sensor, GPIO.IN, GPIO.PUD_DOWN)
previous_state=False
current_state=False
cam=picamera.PiCamera()
frame=5

while True:
    time.sleep(0.000001)
    previous_state=current_state
    current_state=GPIO.input(sensor)
    if current_state!=previous_state:
        new_state="HIGH" if current_state else "LOW"
        print("GPIO pin %s is %s"%(sensor,new_state))
        if current_state:
                fileName=file_name()
                cam.start_preview()
                cam.start_recording(fileName)
                time.sleep(2)
                cam.stop_preview()
                cam.stop_recording()
GPIO.cleanup()     


beta-tester
Posts: 1237
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: how to increase video duration of on going recording

Fri Apr 29, 2016 7:21 pm

i never used the python module, but the raspivid will expect a parameter if you want to record a video longer than 5 sec.
possibly in python you have to provide a similar parameter/attribute as well.


EDIT: forget what i saied.
why do you stop recording after 2 seconds...when you intend to record 20 seconds... ?

Code: Select all

cam.start_recording(fileName)
time.sleep(2)
cam.stop_recording()
Last edited by beta-tester on Fri Apr 29, 2016 7:28 pm, edited 1 time in total.
{ I only give negative feedback }
RPi Model B (rev1, 256MB) & B (rev2, 512MB) & B+, RPi2B, RPi3B, RPi3B+, RPiZeroW, ...

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: how to increase video duration of on going recording

Fri Apr 29, 2016 7:26 pm

Change time.sleep(2) to be time.sleep(20)

himani18
Posts: 44
Joined: Fri Feb 19, 2016 4:52 pm

Re: how to increase video duration of on going recording

Sat Apr 30, 2016 4:37 pm

And is there any way that my motion should not be identified...
Or like if my motion gets detected it should nt record video

User avatar
B.Goode
Posts: 8579
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: how to increase video duration of on going recording

Sat Apr 30, 2016 4:43 pm

himani18 wrote: if my motion gets detected it should nt record video
Just invert the logic of the test at if current_state:

himani18
Posts: 44
Joined: Fri Feb 19, 2016 4:52 pm

Re: how to increase video duration of on going recording

Sun May 01, 2016 12:32 pm

only my motion shouldn't be detected...

it should detect motion of rest of the ppl...

Return to “Beginners”