def main(): info = True photomode = False api = pysony.SonyAPI() search = pysony.ControlPoint() cameras = search.discover(1) if len(cameras): camera = pysony.SonyAPI(QX_ADDR=cameras[0]) else: print("No camera found, aborting") return -1 mode = camera.getAvailableApiList() # For those cameras which need it if 'startRecMode' in (mode['result'])[0]: camera.startRecMode() time.sleep(5) # and re-read capabilities mode = camera.getAvailableApiList() if 'setLiveviewFrameInfo' in (mode['result'])[0]: if info: camera.setLiveviewFrameInfo([{"frameInfo": True}]) else: camera.setLiveviewFrameInfo([{"frameInfo": False}]) url = camera.liveview() #liveview(["L"]) -> large incoming_image = None frame_info = None print("set cam mode") # Ensure that we're in correct mode (movie by default) mode = camera.getAvailableShootMode() if type(mode) == dict: if (mode['result'])[0] != 'movie': if 'movie' in (mode['result'])[1]: camera.setShootMode(["movie"]) #other option: "still" else: photomode = True print("starting stream") lst = api.LiveviewStreamThread(url) lst.start() for i in range(100): print("frame {}".format(i)) header = lst.get_header() if header: image_file = io.BytesIO(lst.get_latest_view()) incoming_image = Image.open(image_file) incoming_image.sav("test.jpg") frame_info = lst.get_frameinfo() print(frame_info) time.sleep(.1) print("stop") api.stopLiveview('1.0')
def setUp(self): if LIVE_CAMERA: multicast_ip = pysony.SSDP_ADDR else: multicast_ip = '224.0.0.111' self.ssdp_server = SSDPServer(multicast_ip) self.ssdp_server.register( manifestation=None, usn=uuid1().urn, st=pysony.SSDP_ST, location='http://127.0.0.1:64321/dd.xml', ) FileRequestHandler.FILE = DD_FILE self.http = HTTPServer(('localhost', 64321), FileRequestHandler) threading.Thread(target=self.ssdp_server.run).start() threading.Thread(target=self.http.serve_forever).start() self.cp = pysony.ControlPoint(multicast_ip)
#!/usr/bin/env python import pysony import base64, hashlib import six print("Searching for camera...") search = pysony.ControlPoint() cameras = search.discover() if len(cameras): camera = pysony.SonyAPI(QX_ADDR=cameras[0]) else: print("No camera found, aborting") quit() # This call fails with a '403 - Permission Error' on the HDR-AS15 (fw V3.0) # Once authenticated it will complete sucessfully # print("Get Movie Quality: %s" % camera.getMovieQuality()) # Tied to Methods list below, 64 _ASCII_ characters = 256 bit equivalant AUTH_CONST_STRING = "35fc6c85705f5b37eb0f31f60c8412644fb2755ff55701e04a82d671c4b5d998" # Enable _Everything_ we know about... # $ grep -e ' def [^_]' src/pysony.py | grep -v -e 'discover(' | sed -e 's/ def /camera\//g' -e 's/(.*/:\\/g' | sort METHODS_TO_ENABLE = "\ avContent/deleteContent:\ avContent/getContentCount:\ avContent/getContentList:\ avContent/getSchemeList:\