Part 2 of my dash cam project. (questions inside!)
#1
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()


Here is my script. It still needs some modification but I would like to see if you guys can help me add some GUI buttons to the preview. Would I use PyXBMCt? Or TkInter? I cant seem to get TkInter installed ( cant download it for some reason). I want to add the following buttons to the preview screen: "Start recording" , "End recording" , and possibly a few buttons for adjusting the time or file name. [/quote]
Reply
#2
tkinter doesn't work with kodi addons afaik. (Someone will correct me if i am wrong).
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
#3
(2017-07-18, 05:12)nickr Wrote: tkinter doesn't work with kodi addons afaik. (Someone will correct me if i am wrong).

Do you think PyXBMCt can be configured to overlay on the preview window?
Reply
#4
Pyxbmct could certainly do the buttons but I'm not sure how you would get the camera preview into the same window.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#5
Perhaps play the preview in Kodi itself?
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
#6
Don't know if that's possible. My understanding was that the start_preview command creates a new video overlay on the screen rather than giving you a stream which could be passed to Kodi.

You could still create the buttons to stop the recording, I'm just not sure if you could have a nice, self-contained window with video and buttons.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#7
Why not just get Kodi to play it, rather than using the built in preview function?

The file is being created and is hopefully playable as it is being written.
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
#8
Yes. That sounds like a neat solution. Worth a try!
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#9
(2017-07-18, 09:05)nickr Wrote: Why not just get Kodi to play it, rather than using the built in preview function?

The file is being created and is hopefully playable as it is being written.

(2017-07-18, 10:05)el_Paraguayo Wrote: Yes. That sounds like a neat solution. Worth a try!

So yes, I am allowed to play the video in Kodi as its recorded. Now, as always, I have questions. IM using Nebula skin, it has pictures for the icons, is it possible to put the video in this? Basically, I would like it to be running and I can click it and see what its recording. I also dont want it to interfere with my music that I will be playing.

Other question, the video has the time and date as stated but it is not changing as the video goes on. Its only the start time.
Reply
#10
I could be wrong but I didn't think it was possible for Kodi to play a video while also playing separate music files.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#11
I think you are correct el_Paraguayo.

I am not sure this requirement has been signalled previously by ablues10.

I might have to find my picamera and experiment.

PS surely:

a. you shouldn't be looking at a video while driving.
b. the preview is looking out the windscreen?
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
#12
I mean I guess you could get really complex and mux the video file with the music you happen to be listening to and pipe it to a file for kodi to play, that way the dashcam footage would always remind you totally of the moment, music and all!
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
#13
(2017-07-19, 10:31)nickr Wrote: a. you shouldn't be looking at a video while driving.
b. the preview is looking out the windscreen?
Funny that the "preview" will be a higher resolution than the recording.

(2017-07-19, 10:33)nickr Wrote: I mean I guess you could get really complex and mux the video file with the music you happen to be listening to and pipe it to a file for kodi to play, that way the dashcam footage would always remind you totally of the moment, music and all!
Complicated and too much for a pi to handle?
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#14
(2017-07-19, 14:30)el_Paraguayo Wrote:
(2017-07-19, 10:31)nickr Wrote: a. you shouldn't be looking at a video while driving.
b. the preview is looking out the windscreen?
Funny that the "preview" will be a higher resolution than the recording.

(2017-07-19, 10:33)nickr Wrote: I mean I guess you could get really complex and mux the video file with the music you happen to be listening to and pipe it to a file for kodi to play, that way the dashcam footage would always remind you totally of the moment, music and all!
Complicated and too much for a pi to handle?

I guess the only reason why I wanted to see the video is to make sure it is recording. Is there another (easier) way to indicate that? I do not have a place for a physical led or anything like that.
Reply
#15
A popup notification would be easy.
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

Logout Mark Read Team Forum Stats Members Help
Part 2 of my dash cam project. (questions inside!)0