Skip to content

sezer-muhammed/Sony-Camera-Manager

Repository files navigation

Sony Sony Camera Manager (Python)

A comprehensive, high-level Python client for controlling Sony cameras (like the ZV-E10, A7RIII, etc.) via the legacy Camera Remote API (JSON-RPC over HTTP).

1) Overview

This package is designed to be the "best ever" implementation for Sony's legacy API, focusing on:

  • Capability-First Architecture: Always probe what the camera supports before calling.
  • Dynamic Method Surface: Use cam.do("methodName", ...) for any method not explicitly wrapped.
  • Robust Liveview: High-performance binary stream parser for JPEG frames.
  • Comprehensive Actions: Full catalog of Sony API methods as constants.

2) Key Features

  • Auto-Discovery: Discover cameras on the network using SSDP.
  • Full Exposure Control: Aperture, Shutter Speed, ISO, Exposure Compensation, etc.
  • Advanced Focus: Focus modes, Touch AF position, Tracking Focus.
  • Live View: Frame-by-frame JPEG extraction from the binary stream.
  • Event Monitoring: Long-polling support to track battery, status, and settings changes.

3) Camera Setup (ZV-E10 & Others)

To use this library, your camera must be configured to accept remote connections over Wi-Fi using the Legacy Camera Remote API.

Required Settings:

Option A: Camera as Access Point (Default)

This is the easiest setup but your PC will lose internet access.

  1. Menu -> Network -> Smartphone Connect -> On.
  2. Connection -> Connect PC to the displayed Wi-Fi.

Option B: Shared Hotspot (Station Mode)

Use this if you need internet access while controlling the camera.

  1. Connect Camera to Hotspot:
    • Menu -> Network -> Wi-Fi -> Access Point Set..
    • Select your hotspot and connect.
  2. Connect PC to Hotspot:
    • Ensure your PC is on the same hotspot.
  3. Enable Remote:
    • Menu -> Network -> Smartphone Connect -> On.
    • The camera should now use the hotspot's network rather than creating its own.

Crucial Notes:

  • Operation State: The camera must be in a shooting mode (Still, Movie, or S&Q).
  • Menu Lock: If you are inside the camera's internal menu, the API will return errors for most commands. Stay on the live shooting screen.
  • Discovery: SSDP (auto-discovery) can be blocked by certain hotspots/routers. If the camera is not found, you will need to find the IP address from your hotspot's client list (usually 192.168.x.x).

4) Installation

pip install sony-camera-manager
# For developers
pip install sony-camera-manager[dev]

4) Usage

4.1 Discovery & Initialization

from sony_camera_manager import SonyCameraClient

# Auto-discovery
host = SonyCameraClient.discover()
if not host:
    host = "192.168.122.1" # Fallback

cam = SonyCameraClient(host=host)

4.2 Probing Capabilities (The Sony Way)

Sony cameras change their available APIs based on their current mode (e.g., Movie vs Still).

# Check what's supported by the hardware
print(cam.get_api_list())

# Check what's available in the current mode
print(cam.get_available_api_list())

# Generic capability helpers
supported_iso = cam.get_supported("IsoSpeedRate")
available_f_numbers = cam.get_available("FNumber")

4.3 High-Level API Examples

from sony_camera_manager.models import ExposureMode

# Set Manual Mode
cam.set_shoot_mode(ExposureMode.MANUAL)

# Adjust Exposure
cam.set_f_number("5.6")
cam.set_shutter_speed("1/100")
cam.set_iso_speed_rate("400")

# Focus tracking
cam.act_tracking_focus(0.5, 0.5) # Center

# Take a photo and wait for result
image_urls = cam.await_take_picture()

4.4 Liveview Stream (OpenCV)

import cv2
import numpy as np

for jpeg in cam.get_liveview_stream():
    img = cv2.imdecode(np.frombuffer(jpeg, np.uint8), cv2.IMREAD_COLOR)
    cv2.imshow('Sony Liveview', img)
    if cv2.waitKey(1) == ord('q'): break

cv2.destroyAllWindows()
cam.stop_liveview()

5) Package Structure

  • SonyCameraClient: Main interface for controlling the camera.
  • transport: Low-level JSON-RPC communication handler (internal).
  • models: Dataclasses and Enums for Camera state and settings.
  • exceptions: Custom exception hierarchy (CameraError, ConnectionError, etc.).

6) References

About

Python-based utility for managing and controlling Sony cameras remotely via API or USB.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages