2017-06-30, 09:07
I can't see why you need user input for the filename at all. Creating a file with a name like "Dashcam-2017-06-30-190525.264" is programmatically simple, logical and pretty typical in this situation.
(2017-06-30, 09:07)nickr Wrote: I can't see why you need user input for the filename at all. Creating a file with a name like "Dashcam-2017-06-30-190525.264" is programmatically simple, logical and pretty typical in this situation.
(2017-06-30, 10:47)el_Paraguayo Wrote: Well, yes, that would be even easier and, more importantly, safer. You don't want to be typing if you're driving!!
# -*- coding: utf-8 -*-
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
import picamera
from time import sleep
# User inputs selected data
# Camera is on for a specified time
camera = picamera.PiCamera()
camera.resolution = (1280, 720)
camera.framrate = (60)
camera.start_recording("Dashcam-2017-06-30-190525H.264")
time.sleep(float(length))
camera.stop_recording()
# Save video in a specified folder
save_path = '/home/pi/picamera'
completed_video = os.path.join(save_path, filename)
from resources.lib import kodiutils
from resources.lib import kodilogging
import logging
import xbmcaddon
import xbmcgui
ADDON = xbmcaddon.Addon()
logger = logging.getLogger(ADDON.getAddonInfo('id'))
# Put your code here, this is just an example showing
# a textbox as soon as this addon gets called
def show_dialog():
addon_name = ADDON.getAddonInfo('name')
line1 = "Hello World!"
xbmcgui.Dialog().ok(addon_name, line1)
findmnt -rn -S UID=38D0-F8E6 -o TARGET
import subprocess
UID = "38D0-F8E6"
cmd = ["findmnt", "-rn", -"S", "UID={0}".format(UID), "-o", "TARGET"]
try:
mount_point = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
# do something with mount_point
except subprocess.CalledProcessError:
# There was an error - command exited with non-zero code
# Could mean the USB wasn't mounted
(2017-06-30, 17:38)el_Paraguayo Wrote: Does LibreElec automount USBs (and does it mount them with read/write permissions)? If so there's a "findmnt" command which may help (I don't know if it's available in LibreElec).
This command:would output the mount point.Code:findmnt -rn -S UID=38D0-F8E6 -o TARGET
You could use this in a python script as follows:
Code:import subprocess
UID = "38D0-F8E6"
cmd = ["findmnt", "-rn", -"S", "UID={0}".format(UID), "-o", "TARGET"]
try:
mount_point = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
# do something with mount_point
except subprocess.CalledProcessError:
# There was an error - command exited with non-zero code
# Could mean the USB wasn't mounted
One question, is your UID correct? I'd expect it to be longer than that.
(2017-06-30, 19:16)el_Paraguayo Wrote: Can you try running the findmnt command? This would be neater than parsing /proc/mounts directly.
(2017-07-01, 00:09)nickr Wrote: Find UUIDs with blkid
Find mount points with mount
Quote:# -*- coding: utf-8 -*-
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
import picamera
from time import sleep
# User inputs selected data
# Camera is on for a specified time
camera = picamera.PiCamera()
camera.resolution = (1280, 720)
camera.framrate = (60)
camera.start_recording("Dashcam-2017-06-30-190525H.264")
time.sleep(float(length))
camera.stop_recording()
# Save video in a specified folder
save_path = '/var/media/Samsung USB'
completed_video = os.path.join(save_path, filename)
from resources.lib import kodiutils
from resources.lib import kodilogging
import logging
import xbmcaddon
import xbmcgui
ADDON = xbmcaddon.Addon()
logger = logging.getLogger(ADDON.getAddonInfo('id'))
# Put your code here, this is just an example showing
# a textbox as soon as this addon gets called
def show_dialog():
addon_name = ADDON.getAddonInfo('name')
line1 = "Hello World!"
xbmcgui.Dialog().ok(addon_name, line1)
# -*- coding: utf-8 -*-
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
import picamera
from time import sleep,strftime,localtime
from resources.lib import kodiutils
from resources.lib import kodilogging
import logging
import xbmcaddon
import xbmcgui
ADDON = xbmcaddon.Addon()
logger = logging.getLogger(ADDON.getAddonInfo('id'))
# Save video in a specified folder
save_path = '/var/media/Samsung USB'
filename = "Dashcam-" + strftime("%Y%m%d%H%M"),localtime + ".264"
completed_video = os.path.join(save_path, filename)
# User inputs selected data
# Camera is on for a specified time
camera = picamera.PiCamera()
camera.resolution = (1280, 720)
camera.framerate = (60)
camera.start_recording(completed_video)
time.sleep(float(length))
camera.stop_recording()