• 1
  • 15
  • 16
  • 17(current)
  • 18
  • 19
  • 20
Release Security CAM Overlay add-on
Ok, so I have v17 kodi and add-on is working... well here goes the question.

1. Is there a way to specify position of the window? I need to move it to the upper right corner of the screen.
2. Is it normal that after activating plugin v17 stops react to any input? Playback is running, but I could not switch back to the movie: UI just not responding to any of my input no meter mouse, keyboard or IR or Android...

Thank you.
Reply
My cam (Amcrest Ultra HD) only allows Digest authentication, so I had to make some script modifications to use the requests python library. Here's my default.py file:

Code:
# Import the modules
import os, requests, time, urllib, urllib2, xbmc, xbmcaddon, xbmcgui, xbmcvfs

# Constants
ACTION_PREVIOUS_MENU = 10
ACTION_BACKSPACE = 110
ACTION_NAV_BACK = 92
ADD_ON_ID = 'script.Cam1'

# Set plugin variables
__addon__    = xbmcaddon.Addon()
__cwd__      = __addon__.getAddonInfo('path').decode("utf-8")
__icon__     = xbmc.translatePath(os.path.join(__cwd__, 'icon.png').encode("utf-8")).decode("utf-8")
__profile__  = xbmc.translatePath(__addon__.getAddonInfo('profile')).decode("utf-8")
__resource__ = xbmc.translatePath(os.path.join(__cwd__, 'resources').encode("utf-8")).decode("utf-8")
__snapshot_dir__ = xbmc.translatePath(os.path.join(__profile__, 'snapshots').encode("utf-8")).decode("utf-8")

# Get settings
url       = __addon__.getSetting('url')
username  = __addon__.getSetting('username')
password  = __addon__.getSetting('password')
width     = int(float(__addon__.getSetting('width')))
height    = int(float(__addon__.getSetting('height')))
interval  = int(float(__addon__.getSetting('interval')))
autoClose = (__addon__.getSetting('autoClose') == 'true')
duration  = int(float(__addon__.getSetting('duration')) * 1000)

# Utils

def log(message,loglevel=xbmc.LOGNOTICE):
    xbmc.log((ADD_ON_ID + ": " + message).encode('UTF-8','replace'),level=loglevel)

# Classes
class CamPreviewDialog(xbmcgui.WindowDialog):
    def __init__(self):
        log('CamPreviewDialog Initialized \n', xbmc.LOGDEBUG)
        COORD_GRID_WIDTH = 1280
        COORD_GRID_HEIGHT = 720
        scaledWidth = int(float(COORD_GRID_WIDTH) / self.getWidth() * width)
        scaledHeight = int(float(COORD_GRID_HEIGHT) / self.getHeight() * height)
        self.image = xbmcgui.ControlImage(COORD_GRID_WIDTH - scaledWidth, COORD_GRID_HEIGHT - scaledHeight, scaledWidth, scaledHeight, __icon__)
        self.addControl(self.image)
        self.image.setAnimations([('WindowOpen', 'effect=slide start=%d time=1000 tween=cubic easing=in'%(scaledWidth),), ('WindowClose', 'effect=slide end=%d time=1000 tween=cubic easing=in'%(scaledWidth),)])

    def start(self, autoClose, duration, interval, url, destination):
        log('CamPreviewDialog Started \n', xbmc.LOGDEBUG)
        self.isRunning = bool(1)
        snapshot = ''
        startTime = time.time()
        while(not autoClose or (time.time() - startTime) * 1000 <= duration):
            if xbmcvfs.exists(snapshot):
                os.remove(snapshot)

            snapshot = self.downloadSnapshot(url, destination)

            if snapshot != '':
                self.update(snapshot)

            xbmc.sleep(interval)
            if not self.isRunning:
                break
        self.close()

    def downloadSnapshot(self, url, destination):
        from requests.auth import HTTPDigestAuth
        log('Retreiving Image \n', xbmc.LOGDEBUG)
        log(destination, xbmc.LOGDEBUG)
        try:
            log('url is ' + url)
            imgData = requests.get(url, auth=HTTPDigestAuth(username, password)).content
            log('1\n', xbmc.LOGDEBUG)
            snapshotpath = os.path.join( destination, 'snapshot' + str(time.time()) + '.jpg' )
            log(snapshotpath, xbmc.LOGDEBUG)
            filename = snapshot = xbmc.translatePath( os.path.join( destination, 'snapshot' + str(time.time()) + '.jpg' ).encode("utf-8") ).decode("utf-8")
            output = open(filename,'wb')
            log('Saving Image To: [' + filename + ']\n', xbmc.LOGDEBUG)
            output.write(imgData)
            output.close()
            return filename
        except Exception, e:
            log('exception\n', xbmc.LOGDEBUG)
            log(str(e), xbmc.LOGDEBUG)
            return ''

    def onAction(self, action):
        log('Received Action: ' + str(action.getId()) + '\n', xbmc.LOGDEBUG)
        if action in (ACTION_PREVIOUS_MENU, ACTION_BACKSPACE, ACTION_NAV_BACK):
            self.isRunning = bool(0)
            self.close()

    def update(self, image):
        log('Updating Image \n', xbmc.LOGDEBUG)
        self.image.setImage(image, bool(0))
    
# Main execution

log('AutoClose: [' + str(autoClose) + ']\n', xbmc.LOGDEBUG)
log('Duration: [' + str(duration) + ']\n', xbmc.LOGDEBUG)
log('Interval: [' + str(interval) + ']\n', xbmc.LOGDEBUG)
log('Width: [' + str(width) + ']\n', xbmc.LOGDEBUG)
log('Height: [' + str(height) + ']\n', xbmc.LOGDEBUG)
log('Original URL: [' + url + ']\n', xbmc.LOGDEBUG)

# Add Basic Authentication Headers
if (username is not None and username != ''):
    passwordManager = urllib2.HTTPPasswordMgrWithDefaultRealm()
    passwordManager.add_password(None, url, username, password)
    authhandler = urllib2.HTTPBasicAuthHandler(passwordManager)
    opener = urllib2.build_opener(authhandler)
    urllib2.install_opener(opener)

# Replace URL agruments
argCount = len(sys.argv)
for i in xrange(1, argCount):
    search = '{%d}'%(i - 1)
    replace = sys.argv[i]
    url.replace(search, replace)

log('Final URL: [' + url + ']\n', xbmc.LOGDEBUG)

xbmcvfs.mkdir(__snapshot_dir__)

camPreview = CamPreviewDialog()
camPreview.show()
camPreview.start(autoClose, duration, interval, url, __snapshot_dir__)
del camPreview

dirs, files = xbmcvfs.listdir(__snapshot_dir__)
for file in files:
    log('Delete remaining snapshot: [' + file + ']\n', xbmc.LOGDEBUG)
    xbmcvfs.delete(os.path.join(__snapshot_dir__, file))
Reply
is there a way to get this to work with DVR camera systems that have 4 channels and port login/pass etc?


@Karellen- Quotes removed
Reply
@cerbeing

No need to quote when replying, especially with logs in the quote. A simple @iantivey at the start of the message, and members can figure out who your message is directed at


@iantivey
No logs in the forum. In future use Pastebin type site and provide the link back here.
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
It wasn't a log, it was the paste of a python file, but the principle is the same.

However for code, the best practice is to fork the code on github and post a link to that. Distributing code via pastebin is just dumb and amateur.
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
(2017-06-17, 22:19)kaim Wrote: Ok, so I have v17 kodi and add-on is working... well here goes the question.

1. Is there a way to specify position of the window? I need to move it to the upper right corner of the screen.
2. Is it normal that after activating plugin v17 stops react to any input? Playback is running, but I could not switch back to the movie: UI just not responding to any of my input no meter mouse, keyboard or IR or Android...

Thank you.
Did you ever get this working?

Sent from my SM-G950U
I'm not an expert but I play one at work.
Reply
Does anyone have this working on Kodi v18. Im not sure what changed since 17 and 18 but I have this connected to a BlueIris camera stream and it stops refreshing. From BlueIris it looks like it is trying to open a bunch of different streams and quickly maxes out the max users Sad 17 had no issues like this
Reply
This is exactly what I needed... Kodi 17 with my openhab server so firing it off with the doorbell and pausing Kodi.

Thankyou!
Reply
Dears,

This is a cool add-on for home automation, and I really would like to get it going with my doorbird doorbell.
Doorbird has an open api, this is why i bought it actually.

But some how I can not get it to work with this addon.

Below options are possible:
http://<device-ip>/bha-api/video.cgi  --> give a video feed (MJPEG)
http://<device-ip>/bha-api/image.cgi --> gives an image (JPG)

Both commands work if i try them in a webbrowser, but unfortunately not in the addon
Reply
(2018-07-29, 23:08)skarragallagher Wrote: Does anyone have this working on Kodi v18. Im not sure what changed since 17 and 18 but I have this connected to a BlueIris camera stream and it stops refreshing. From BlueIris it looks like it is trying to open a bunch of different streams and quickly maxes out the max users Sad 17 had no issues like this
 +1 FOR KODI 18
Reply
This is an add on I have been making very good use of for years now and a reason why I won’t upgrade to 18 for now at least...will read any further reports with interest but will look to build a test machine on a spare computer at some point to see how things are looking
Reply
If you are interested in an updated version that supports multiple cam feeds, positioning of the overlay window(s) and that is compatible with kodi 18 you may want to look here.
Reply
Is there a similar addon that can also cause a pop-up window, but only with the broadcast of the video stream, and not from the jpg image?
Reply
(2019-03-30, 17:12)Spirou Wrote: If you are interested in an updated version that supports multiple cam feeds, positioning of the overlay window(s) and that is compatible with kodi 18 you may want to look here.

thanks.  how is it working for you?
Reply
(2019-03-30, 17:12)Spirou Wrote: If you are interested in an updated version that supports multiple cam feeds, positioning of the overlay window(s) and that is compatible with kodi 18 you may want to look here.
Great find, thank you.
What you have to specify to get all four camera snapshots to pop up at the same time, while keeping the original Aspect Ratio (16:9), let's say at 480x270 snapshot on a 1920x1080 screen?
Reply
  • 1
  • 15
  • 16
  • 17(current)
  • 18
  • 19
  • 20

Logout Mark Read Team Forum Stats Members Help
Security CAM Overlay add-on1