powergravity
Posts: 32
Joined: Sun Dec 25, 2016 12:44 pm

stop raspivid process

Mon Jan 09, 2017 7:28 pm

Hello,

I have some difficulties to stop the raspivid function. I am trying ta start/stop recordings from the GPIO with a button. According to the following code, start the video recording works perfectly but impossible to stop it.
I have tried to use popen.kill(), popen.terminate(), subprocess.cal('pkill raspivid', shell=True), ... but nothing works :cry:

Code: Select all

import RPi.GPIO as GPIO
import subprocess
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
while True:
        GPIO.wait_for_edge(17, GPIO.RISING)
        print("RecordingVideo")
        subprocess.call('raspivid -w 640 -h 480 -fps 90 -t 9999 -o slowmotion.h264')
        GPIO.wait_for_edge(17, GPIO.RISING)
        print("Stopped")
        subprocess.call('pkill raspivid')
GPIO.cleanup()
I would appreciate some help.

Thank you in advance,
Pm

User avatar
yertiz
Posts: 34
Joined: Mon Apr 16, 2012 3:45 pm

Re: stop raspivid process

Wed Jan 11, 2017 4:59 pm

Have you tried importing

Code: Select all

picamera
and using

Code: Select all

 camera.start _recording()
and

Code: Select all

camera.stop_recording() 
which usually works for me?

Return to “Camera board”