video.h264
.I have tried all sorts of things that I have found on the net, but they only result in the file name showing part of the code. Annoyingly it worked once, but saved it to somewhere I was not expecting and I changed the code before I realized it had worked!
# Import Libraries
import os #Gives Python access to Linux commands
import time #Proves time related commands
import RPi.GPIO as GPIO #Gives Python access to the GPIO pins
GPIO.setmode(GPIO.BCM) #Set the GPIO pin naming mode
GPIO.setwarnings(False) #Supress warnings
# Set GPIO pins 18 as output pin
LEDReady = 18 #Red
GPIO.setup(LEDReady,GPIO.OUT)
GPIO.output (LEDReady,GPIO.HIGH)
from subprocess import call
call(["raspivid", "-o", "video.h264", "-t", "50000n"])
time.sleep(10) #Sleep for 10 seconds
GPIO.output (LEDReady,GPIO.LOW)
Adding DATE=$(date +"%Y-%m-%d_%H%M")
and changing video.h264
to $DATE.h264
results in a syntax error for $DATE.
Tantalizingly, I have a file called 20180308_021941.h264 which is exactly what I am after, but I cannot tell you how I managed it!
P.S. the Red LED lighting up is so that I can tell if the Raspberry Pi has fired up properly and has run the Python script.
Thank you for taking the trouble to read this.
Try adding this
from datetime import datetime
date = datetime.now().strftime("%Y%m%d%H:%M:%S")
Then change your call to this
videoFile = date + ".h264"
call(["raspivid", "-o", videoFile, "-t", "50000n"])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With