How is possible to capture a screenshot on realtime video and send it via FTP or SSH every 10 min?

SOLVED
pla_zetel
Conversationalist

How is possible to capture a screenshot on realtime video and send it via FTP or SSH every 10 min?

In a public environnement we are interested to capture a screenshot on the real time video 

and send this via FTP or SSH to a web site 

Someone can help me to understand if this is possible on meraki MV71 camera and related platform?

Regards

1 ACCEPTED SOLUTION
GeorgeB
Meraki Employee
Meraki Employee

Although this is not a feature we have today, you can try the Pyhton script below courtesy of the Meraki Systems Engineering team. Note that this is provided as is with no support. It may not work, if it does work it may stop working at any time.

 

#!/usr/bin/python3

'''
=== PREREQUISITES ===
Run in Python 3 or 2

Install selenium, via macOS terminal:
Python 3 > pip3 install selenium
Python 2 > sudo pip install selenium

Install Chrome driver:
brew install chromedriver

Usage:
Python 3 > python3 screenshot.py
Python 2 > python screenshot.py

=== DESCRIPTION ===
UI script to take a screenshot every x seconds, given camera input link, until script manually terminated (control-C).
'''

import datetime
import time
import glob
import os
from selenium import webdriver
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

# Default Chrome download folder:
FILE_PATH="your local path"


# If using Python 2
try: input = raw_input
except NameError: pass

# Generic parse function
def parse(text, beg_tag, end_tag, beg_pos=0, end_pos=-1):
    if text.find(beg_tag, beg_pos, end_pos) == -1:
        return ('', -1)
    else:
        initial = text.find(beg_tag, beg_pos, end_pos) + len(beg_tag)
    if text.find(end_tag, initial) == -1:
        return ('', -1)
    else:
        final = text.find(end_tag, initial)
    return (text[initial:final], final+len(end_tag))

# Login to Dashboard
def login(driver):
    while True:
        # For convenience, option to store credentials in separate login.py file, although unsecure since cleartext
        try:
            import login
            (DASHBOARD_EMAIL, DASHBOARD_PASSWORD) = (login.email, login.password)
        except ImportError:
            DASHBOARD_EMAIL = input('Enter your Dashboard account email adddress: ')
            DASHBOARD_PASSWORD = input('Enter your Dashboard account password: ')

        print('Loading Selenium headless browser...')
        login_url = 'https://account.meraki.com/login/login'

        driver.get(login_url)
        driver.find_element_by_id('email').send_keys(DASHBOARD_EMAIL)
        driver.find_element_by_id('password').send_keys(DASHBOARD_PASSWORD)
        driver.find_element_by_id('commit').click()

        # Check credentials
        if 'Invalid email/password combination' in driver.page_source:
            print('Invalid Dashboard email/password combination, please try again!\n')
            continue
        else:
            print('Successfully logged into Dashboard as ' + DASHBOARD_EMAIL)
            break

    # Verify two-factor authentication code
    while 'Enter verification code' in driver.page_source:
        code = input('Enter two-factor authentication code: ')
        input_element = driver.find_element_by_id('code')
        input_element.send_keys(code)
        input_element.submit()

        # Check code
        if 'Invalid verification code' in driver.page_source:
            print('Invalid verification code, please try again!\n')
            continue
        else:
            break


if __name__ == '__main__':
    #driver = webdriver.PhantomJS()
    driver = webdriver.Chrome()
    login(driver)

    # Input MV video link from Dashboard
    while True:
        url = input('Enter link to camera page, which ends in "/manage/nodes/new_list/[node_id]":\n')
        url = url.rstrip('/')
        # Error checking for layer 8 issues
        if 'nodes/new_list' not in url:
            print('Invalid link to camera page, please try again!\n')
            continue
        else:
            break
    driver.get(url)
    driver.implicitly_wait(20)

    while True:
        time.sleep(5)
        # Downloads screenshot into default folder of the browser settings. No dialogue box presented.
        driver.find_element_by_css_selector('.IconButton.subtle.ScreenshotButton.btn.btn-default').click()
        print('Took screenshot at ' + str(datetime.datetime.now()))

View solution in original post

4 REPLIES 4
JPena
Meraki Employee
Meraki Employee

I don't believe MV cameras support that functionality. I know this isn't very helpful, but drop it in the 'make a wish' box in your dashboard.
Jose Pena
Network Support Engineer @ Cisco Meraki .:|:.:|:.
GeorgeB
Meraki Employee
Meraki Employee

Although this is not a feature we have today, you can try the Pyhton script below courtesy of the Meraki Systems Engineering team. Note that this is provided as is with no support. It may not work, if it does work it may stop working at any time.

 

#!/usr/bin/python3

'''
=== PREREQUISITES ===
Run in Python 3 or 2

Install selenium, via macOS terminal:
Python 3 > pip3 install selenium
Python 2 > sudo pip install selenium

Install Chrome driver:
brew install chromedriver

Usage:
Python 3 > python3 screenshot.py
Python 2 > python screenshot.py

=== DESCRIPTION ===
UI script to take a screenshot every x seconds, given camera input link, until script manually terminated (control-C).
'''

import datetime
import time
import glob
import os
from selenium import webdriver
from selenium.webdriver.support.ui import Select, WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

# Default Chrome download folder:
FILE_PATH="your local path"


# If using Python 2
try: input = raw_input
except NameError: pass

# Generic parse function
def parse(text, beg_tag, end_tag, beg_pos=0, end_pos=-1):
    if text.find(beg_tag, beg_pos, end_pos) == -1:
        return ('', -1)
    else:
        initial = text.find(beg_tag, beg_pos, end_pos) + len(beg_tag)
    if text.find(end_tag, initial) == -1:
        return ('', -1)
    else:
        final = text.find(end_tag, initial)
    return (text[initial:final], final+len(end_tag))

# Login to Dashboard
def login(driver):
    while True:
        # For convenience, option to store credentials in separate login.py file, although unsecure since cleartext
        try:
            import login
            (DASHBOARD_EMAIL, DASHBOARD_PASSWORD) = (login.email, login.password)
        except ImportError:
            DASHBOARD_EMAIL = input('Enter your Dashboard account email adddress: ')
            DASHBOARD_PASSWORD = input('Enter your Dashboard account password: ')

        print('Loading Selenium headless browser...')
        login_url = 'https://account.meraki.com/login/login'

        driver.get(login_url)
        driver.find_element_by_id('email').send_keys(DASHBOARD_EMAIL)
        driver.find_element_by_id('password').send_keys(DASHBOARD_PASSWORD)
        driver.find_element_by_id('commit').click()

        # Check credentials
        if 'Invalid email/password combination' in driver.page_source:
            print('Invalid Dashboard email/password combination, please try again!\n')
            continue
        else:
            print('Successfully logged into Dashboard as ' + DASHBOARD_EMAIL)
            break

    # Verify two-factor authentication code
    while 'Enter verification code' in driver.page_source:
        code = input('Enter two-factor authentication code: ')
        input_element = driver.find_element_by_id('code')
        input_element.send_keys(code)
        input_element.submit()

        # Check code
        if 'Invalid verification code' in driver.page_source:
            print('Invalid verification code, please try again!\n')
            continue
        else:
            break


if __name__ == '__main__':
    #driver = webdriver.PhantomJS()
    driver = webdriver.Chrome()
    login(driver)

    # Input MV video link from Dashboard
    while True:
        url = input('Enter link to camera page, which ends in "/manage/nodes/new_list/[node_id]":\n')
        url = url.rstrip('/')
        # Error checking for layer 8 issues
        if 'nodes/new_list' not in url:
            print('Invalid link to camera page, please try again!\n')
            continue
        else:
            break
    driver.get(url)
    driver.implicitly_wait(20)

    while True:
        time.sleep(5)
        # Downloads screenshot into default folder of the browser settings. No dialogue box presented.
        driver.find_element_by_css_selector('.IconButton.subtle.ScreenshotButton.btn.btn-default').click()
        print('Took screenshot at ' + str(datetime.datetime.now()))

pla_zetel
Conversationalist

Thank you George
i will try this solution
Thanks a lot
Pierre

did this python script work for you

Get notified when there are additional replies to this discussion.
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.