Skip to content

Add minimum zoom scale support and custom video output URL#281

Open
shabbirv wants to merge 5 commits intoimaginary-cloud:masterfrom
shabbirv:claude/add-zoom-support-0jJU1
Open

Add minimum zoom scale support and custom video output URL#281
shabbirv wants to merge 5 commits intoimaginary-cloud:masterfrom
shabbirv:claude/add-zoom-support-0jJU1

Conversation

@shabbirv
Copy link

Summary

Enhanced the camera manager's zoom functionality to support minimum zoom levels and added the ability to specify a custom output URL when recording videos.

Key Changes

  • Minimum zoom scale support: Added minZoomScale property that automatically detects and uses the device's minimum available video zoom factor (e.g., ultra-wide camera on iPhone 11+)
  • Custom video recording URL: Modified startRecordingVideo() to accept an optional url parameter, allowing callers to specify a custom output path instead of always using the temporary directory
  • Zoom range calculation: Updated _setupMaxZoomScale() to query both maxAvailableVideoZoomFactor and minAvailableVideoZoomFactor from the active camera device
  • Zoom constraint fix: Changed zoom calculation to respect minimum zoom scale: max(minZoomScale, min(...)) instead of hardcoded max(1.0, ...)
  • Documentation updates: Updated README with examples of zooming out and clarified that zoom range is automatically determined by device capabilities

Implementation Details

  • The minimum zoom scale is automatically set during camera setup, eliminating the need for manual configuration
  • The custom URL parameter in startRecordingVideo() is optional and defaults to the existing temporary file path behavior for backward compatibility
  • Zoom constraints now properly support devices with ultra-wide lenses by allowing zoom values below 1.0

https://claude.ai/code/session_01KpFgCpFkFy6d6S2V73DQqm

Shabbir Vijapura and others added 5 commits July 16, 2024 12:38
Changed minimum zoom level from 1.0x to 0.5x to support newer cameras
with ultra-wide lenses. Updated documentation to reflect the new zoom
range (0.5x to device maximum).

https://claude.ai/code/session_01KpFgCpFkFy6d6S2V73DQqm
Changed zoom implementation to dynamically detect minimum zoom level
using minAvailableVideoZoomFactor from the camera device. This ensures
ultra-wide cameras are properly supported only on devices that have them.

- Added minZoomScale property to track device minimum zoom
- Updated _setupMaxZoomScale() to set both min and max zoom limits
- Changed _zoom() to use dynamic minZoomScale instead of hardcoded 0.5
- Updated README to clarify that zoom range is device-dependent

On multi-camera devices (iPhone 11+), the minimum zoom factor is 1.0,
which automatically uses the ultra-wide lens. This is the correct iOS
behavior rather than using an arbitrary 0.5x value.

https://claude.ai/code/session_01KpFgCpFkFy6d6S2V73DQqm
The previous implementation only selected the first back camera device,
which would return the basic wide-angle camera without ultra-wide support.

Changed camera discovery to use AVCaptureDevice.DiscoverySession with
priority order:
1. .builtInTripleCamera (iPhone 11 Pro+, supports ultra-wide)
2. .builtInDualWideCamera (iPhone 11/13/14, supports ultra-wide)
3. .builtInDualCamera (older dual camera models)
4. .builtInWideAngleCamera (fallback for single camera devices)

This ensures that on devices with ultra-wide cameras (iPhone 11+), the
multi-camera virtual device is selected, which allows iOS to automatically
switch to the ultra-wide lens when zoom is set to 1.0.

Updated README to explain which device types are now supported and how
ultra-wide camera switching works.

https://claude.ai/code/session_01KpFgCpFkFy6d6S2V73DQqm
On multi-camera devices with ultra-wide cameras, the default zoom now
starts at the first switchover point (e.g., 2.0) which represents the
main wide-angle camera at "1x" zoom - matching the default Camera app behavior.

Changes:
- Detect virtualDeviceSwitchOverVideoZoomFactors on iOS 13+
- Set initial zoom to first switchover point for multi-camera devices
- Change _zoom(0) to _zoom(1) to maintain the default zoom level
- Fallback to minimum zoom for single-camera devices

This fixes the issue where the camera would start at the ultra-wide lens
(0.5x zoom) instead of the expected wide-angle lens (1x zoom).

https://claude.ai/code/session_01KpFgCpFkFy6d6S2V73DQqm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants