Addon for Picamera (video)
#31
PS you'd be better using a setting for the directory to record to.

Oh and length isn't defined. Probably best in a setting too.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#32
(2017-07-02, 09:04)nickr Wrote: PS you'd be better using a setting for the directory to record to.

Oh and length isn't defined. Probably best in a setting too.

Code:
# -*- 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.wait_recording(5)
camera.stop_recording()

https://pastebin.com/yWGs0Eb0
Reply
#33
oops, change
Code:
filename = "Dashcam-" + strftime("%Y%m%d%H%M"),localtime + ".264"
to
Code:
filename = "Dashcam-" + strftime("%Y%m%d%H%M", localtime()) + ".264"

But you still haven't defined length. As I say that is probably best done as a setting.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#34
(2017-07-02, 22:44)nickr Wrote: oops, change
Code:
filename = "Dashcam-" + strftime("%Y%m%d%H%M"),localtime + ".264"
to
Code:
filename = "Dashcam-" + strftime("%Y%m%d%H%M", localtime()) + ".264"

But you still haven't defined length. As I say that is probably best done as a setting.

How do I define that? Im thinking 1 hour length.

I have a new error after changing that. https://pastebin.com/F8e7YLh0
Reply
#35
Come on at some point you do have to do some research for yourself:

http://kodi.wiki/view/Add-on_settings
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#36
(2017-07-03, 00:27)nickr Wrote: Come on at some point you do have to do some research for yourself:

http://kodi.wiki/view/Add-on_settings

Sorry, ok, I started building my settings, im sure I will have questions soon lol. Im still having this error though:
Quote: PiCameraValueError: Unable to determine type from filename /var/media/Samsung USB/Dashcam-201707022326.264
Reply
#37
Reading the docs, i think it should be .h264 not .264
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#38
(2017-07-03, 02:32)nickr Wrote: Reading the docs, i think it should be .h264 not .264

Ok, I think that worked but now im having resource problems.
https://pastebin.com/uUzG6jKd Confused
Reply
#39
That is not a kodi error, but a problem in some way with the pi and/or the camera.

Google the error message.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#40
(2017-07-03, 04:24)nickr Wrote: That is not a kodi error, but a problem in some way with the pi and/or the camera.

Google the error message.

I found this but since I can't sudo and things are so different in Kodi/Libreelec,
Quote:The Raspberry Pi Camera Module uses the onboard GPU and its memory. Since your error message mentions being out of resources, consider adding at least (and possibly more than) the recommended minimum of 128MB to the GPU's allotment.

To change it:

sudo raspi-config
select: Advanced options -> Memory split -> and set at least 128MB

Some users report this message disappearing after changing the GPU memory allotment to 256MB from 128MB.
Reply
#41
Your GPU is set to 256M. You don't need to change that.

Libreelec doesn't need sudo as you are logged in as root anyway.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#42
(2017-07-03, 06:19)nickr Wrote: Your GPU is set to 256M. You don't need to change that.

Libreelec doesn't need sudo as you are logged in as root anyway.

I found that it IS recording video. I think its not ending the script correctly, and thats why it says its out of resources. Do you have any solutions?

Also it recorded 4 separate files. Is there a way to overwrite older files once it reaches a certain capacity?
Reply
#43
That is a programming exercise for you.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#44
(2017-07-05, 04:45)nickr Wrote: That is a programming exercise for you.

Ok, I got it figured out. Now, I few things I havent been able to find when I was doing research:

1. The time that is on the camera preview does not change after it has started.
2. How can I make it RE-record over the existing files automatically? (So I don not have to keep going in and deleting them myself)
3. I need to find out how to end the camera preview or restart it via button or mouse click. (can this be its own separate addon?) I found this but cant figure out how to get it: "tkinter". If I can open a preview with mouse click and close with an "X" that would be awesome.

Here is my script now:

Code:
# -*- coding: utf-8 -*-
import os
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
import datetime as dt
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()) + ".h264"

completed_video = os.path.join(save_path, filename)

# User inputs selected data
# Camera is on for a specified time
camera = picamera.PiCamera()
try:
    camera.resolution = (1280, 720)
    camera.framerate = (60)
    camera.start_recording(completed_video)
    camera.start_preview(fullscreen=False, window = (100, 20, 640, 480))
    camera.annotate_background = picamera.Color('black')
        camera.annotate_text = dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    start = dt.datetime.now()
        camera.annotate_text = dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    camera.wait_recording(3600)
    camera.stop_preview()
    camera.stop_recording()
finally:
    camera.close()
Reply

Logout Mark Read Team Forum Stats Members Help
Addon for Picamera (video)0