Skip to content
Projects

Vovento/bm4k-autofocus

View on GitHub

About

Use BMPCC 4K as a webcam on macOS with face-tracking autofocus and a local camera control dashboard

Design & Media

How these counts are measured

Measured star growth

in 24h
Collecting history
in 7 days
Collecting history
in 15 days
Collecting history
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

BM4K Autofocus — face-tracking autofocus for a BMPCC 4K webcam

Use a Blackmagic Pocket Cinema Camera 4K as a webcam on macOS, with face-tracking autofocus and a local camera control dashboard. The camera supplies the video feed over USB-C; BM4K Autofocus adjusts the lens over Bluetooth while you use that feed in Zoom or another video app.

BM4K Autofocus watches the Blackmagic video feed with Apple Vision, tracks a face, evaluates sharpness, and sends focus commands over Bluetooth Low Energy. The browser dashboard shows the camera preview and controls focus, iris, shutter angle, ISO, white balance, recording format, codec and quality, recording, and supported image and audio settings. It can also drive a tested PDMOVIE focus motor for manual lenses.

This is not a virtual webcam or a video forwarding app. Select the Pocket Cinema Camera itself as the video source in Zoom or another app; BM4K Autofocus runs alongside it to control the camera. The dashboard and face tracking use the same Blackmagic video feed. Built-in Mac, iPhone and generic capture cameras are rejected as autofocus sources.

Hardware tested: BMPCC 4K, Sigma 18–35 mm f/1.8 Art EF, Metabones Speed Booster 0.64× EF–MFT, macOS. A Canon EF 24–105 mm f/4L has also been used with the same adapter. Manual-lens motor control has been tested with a PDMOVIE LIVE AIR 4 SMART / PD-BTMP-SPM, a Samyang 24 mm T1.5, and Veydra Mini Prime 25 mm and 50 mm lenses in one local setup. Results vary with light, distance, lens and motor mounting. BMPCC 6K models and other motor systems remain unverified; contributions and test results are welcome.

An experimental focus-position curve is also included for a Canon EF 24–105 mm f/4L IS USM through the same Metabones 0.64× adapter on BMPCC 4K. It was measured after switching the lens to AF and covers camera-reported distances of about 88 mm to 2.3 m. Face tracking ran with that profile in one close-range session; it has not been validated across distances, lighting or users. The focus model's sharpness parameters are still provisional for this lens.

Unofficial community project. Not affiliated with or endorsed by Blackmagic Design. Blackmagic and Pocket Cinema Camera are trademarks of their respective owner.

Set up your BMPCC 4K webcam

Choose either installation path below. Both end with selecting Pocket Cinema Camera as the video source in your meeting or streaming app. BM4K Autofocus controls the physical camera's focus; it does not create a separate webcam device.

Option A: ask your coding agent to install it

Give your coding agent the repository link and this instruction:

Install BM4K Autofocus on my Mac using its README and install.sh. Check that my Python version is supported, install the required dependencies, and launch the dashboard. Ask me to enable Bluetooth on the Mac and BMPCC 4K, connect the camera over USB-C in webcam mode, and approve any macOS Camera/Bluetooth permission prompts. Verify that the dashboard detects the Blackmagic video feed and Bluetooth link; do not select my MacBook or iPhone camera. Ask whether I want the service to start at login. Explain how to select Pocket Cinema Camera as the webcam in my video app.

Stay with the agent for physical camera settings and macOS permission prompts. The agent cannot turn on the camera's Bluetooth or approve those prompts for you.

Option B: install it yourself

  1. On the BMPCC 4K, enable Bluetooth in Menu → Setup → Bluetooth. On the Mac, turn Bluetooth on. Disconnect Blackmagic's phone control app if it is connected; the camera accepts one BLE controller at a time.

  2. Connect the camera to the Mac with a USB-C data cable. Enable the camera's webcam/USB video output and confirm that macOS lists Pocket Cinema Camera as a camera. Keep the camera powered on.

  3. Ensure you have macOS, Python 3.9–3.12, and Xcode Command Line Tools. If needed, install the tools with xcode-select --install. Check Python with python3 --version.

  4. In Terminal, run:

    git clone https://github.com/Vovento/bm4k-autofocus.git
    cd bm4k-autofocus
    ./install.sh
    
  5. When the installer asks, choose whether to start the service automatically at login. Then open BM4K Autofocus.app from the cloned folder. It opens the dashboard at http://127.0.0.1:8765.

  6. On first launch, grant Camera and Bluetooth access to BM4K Autofocus Service in macOS System Settings → Privacy & Security when prompted. Complete any camera pairing prompt on the Mac.

  7. In the dashboard, wait for the Blackmagic Bluetooth link and camera preview, then enable Follow face. The app will use only the Blackmagic video device for tracking; it will not switch to the MacBook or iPhone camera.

  8. In Zoom, OBS, or your other video app, select Pocket Cinema Camera as the camera/webcam. Keep BM4K Autofocus running alongside it for autofocus. Select your preferred microphone separately in that app.

If you have a different lens or a BMPCC 6K, read Lens profiles and compatibility before relying on autofocus; the tested setups are listed above.

What it does

  • Precise tracking: estimates subject distance from face size and focal length, uses the lens profile to command focus position, then verifies/refines it using image sharpness. The built-in one-shot AF is used for initial learning and fallback.
  • Camera AF fallback: when a lens does not report focus distance, the app can use the camera's one-shot AF. That AF targets the centre of the frame, so off-centre faces may not be focused in fallback mode.
  • Local dashboard: MJPEG preview, focus status and controls. It binds to 127.0.0.1:8765; it is not exposed to the network.
  • Manual-lens autofocus: the experimental PDMOVIE driver moves a geared manual lens while Apple Vision tracks the face and checks image sharpness. The motor panel can be collapsed when unused.
  • Reconnects: the background service retries Bluetooth and video capture when the camera is disconnected or restarted. The first UVC open can occasionally take another attempt.

Camera and lens selection

The bottom of the dashboard's left column has Camera & lens selectors. Camera selection can restrict both Bluetooth and USB video to a Pocket Cinema Camera 4K, 6K, 6K Pro or 6K G2; automatic detection remains the default. Changing the camera stops autofocus and reconnects the service. It is blocked during recording. The 6K variants are experimental choices, not verified autofocus support. Their recording format controls remain unavailable until their modes have been validated. The original 2013 Pocket Cinema Camera is not listed: it does not provide the Bluetooth and direct USB webcam workflow this application uses.

The lens selector shows profiles already saved on this Mac and the lens name reported by the connected camera. Automatic lens detection is the default. Selecting a specific profile makes autofocus wait until the camera reports that lens, so another lens cannot inherit its calibration. An unrecognised electronic lens gets its own profile and learning data; the first calibration sweeps the focus range for about a minute. Set the lens's physical AF/MF switch to AF before calibration. If a sweep produced no usable curve, use Recalibrate attached lens after checking the switch. A previously valid curve is kept if the retry fails. A manual lens without camera focus control needs an external motor; selecting a lens profile alone cannot drive it.

Experimental PDMOVIE autofocus for manual lenses

The dashboard can connect directly over Bluetooth to the tested PDMOVIE LIVE AIR 4 SMART / PD-BTMP-SPM motor and send absolute motor-position commands. The motor can power itself from its battery or charge over USB-C; the current app control path is Bluetooth. This feature uses the Blackmagic webcam image and Apple Vision, not a LiDAR distance stream. The motor's read-only BLE characteristics did not expose verified LiDAR range or encoder feedback in our tests. See PDMOVIE BLE findings for the observations and limits.

To try it with a manual lens:

  1. Mount the lens and motor, engage the gear with the focus ring, and connect the BMPCC 4K as a USB webcam. Keep camera Bluetooth enabled. Turn on the motor.
  2. Expand PDMOVIE focus motor at the bottom of the dashboard's left column. Select the mounted lens or choose New lens profile… to create a separate profile for another setup.
  3. Press Connect motor. This establishes the BLE link without moving the lens. The motor's own LiDAR autofocus must be paused, with the left focus-channel light off and the motor pause released, for Mac position commands to hold the focus.
  4. Press Calibrate this lens. The motor's built-in calibration sweeps the ring to both physical stops; then the app searches the webcam image for sharp focus. Keep the subject still during the first image search and check the result in your video app. The physical sweep took about 25 seconds on the tested Samyang setup; total setup time varies with lens travel.
  5. Enable Follow face with motor. The app saves learned focus points to this lens's local profile and can add or refine points as it observes new distances and verified sharpness. If you change the lens, motor position, gear engagement or physical calibration, select the corresponding profile and calibrate again.

The numeric slider shows raw BLE command values from 0 to 65535, not measured lens-stop coordinates. The app cannot read physical stop positions from the tested BLE interface. After a sweep, it can stop an image search when repeated commands no longer change the image, but this is an estimate, not motor telemetry. A lens's saved motor positions are specific to its mounting and calibration; they are not automatically transferable even to another copy of the same lens. Other PDMOVIE models, DJI Focus systems and other motors need separate drivers and hardware validation. PDMOVIE's product page describes an RS485 interface that requires dedicated firmware and vendor protocol documentation; this app does not use it.

Recording format controls

With a connected BMPCC 4K, the dashboard can change recording codec and quality: ProRes 422 HQ, 422, LT or Proxy, and Blackmagic RAW Q0, Q1, Q3, Q5, 3:1, 5:1, 8:1 or 12:1. It also controls recording resolution and project frame rate with buttons for the available values (23.976, 24, 25, 30, 50 or 60 fps). The codec choices follow the current resolution and sensor scan; the resolution list follows the current codec. The dashboard waits for the camera to report each format change. These controls have not been validated on 6K bodies.

The camera also has a separate off-speed sensor frame rate. For example, choose HD windowed or 2.6K 16:9, then select 120 fps under High-speed sensor rate. Other modes top out at 60 fps (4K DCI/UHD), 75 fps (4K 2.4:1), or 80 fps (2.8K anamorphic). HD ProRes with the full sensor remains limited to 60 fps. Switching to a mode with a lower maximum automatically turns off an unsupported off-speed rate.

Off-speed 120/24 captures 120 sensor frames per second but plays the recorded clip at the 24 fps project rate, producing slow motion; audio may not stay in sync. This does not guarantee a 120 fps USB webcam feed in Zoom, OBS, or another video app. The app does not control the frame rate negotiated by those apps. See the BMPCC 4K maximum sensor frame rate table and Blackmagic Camera Control protocol.

Other remote camera settings

The dashboard exposes sharpening, auto exposure and timecode source, plus headphone level, headphone program mix, speaker level and phantom power when the connected camera reports those settings over Bluetooth. Controls without a camera state are hidden. Focus, iris, shutter, ISO, white balance, recording, microphone level and input remain available as before. The advanced image controls check the camera's reported value after a change and show an error if it is not confirmed. Dynamic range and Display LUT were removed from the dashboard after the tested BMPCC 4K ignored their BLE commands.

The Blackmagic Camera Control protocol describes commands for several camera families. This dashboard exposes only the settings above for the BMPCC 4K; it does not claim support for every generic protocol command, storage operation or live-streaming command. Codec switching and the additional controls have been checked with the protocol encoder and dashboard simulator; hardware support still varies. Please report camera model, firmware, selected resolution and codec if a setting is rejected or not reflected back.

Requirements

  • macOS, Python 3.9–3.12, and Xcode Command Line Tools (xcode-select --install for clang). The pinned dependencies have not been validated with Python 3.13+.
  • Blackmagic Pocket Cinema Camera 4K with USB webcam output enabled and a USB-C data connection to the Mac.
  • Bluetooth enabled on the Mac and camera (camera Menu → Setup → Bluetooth). Disconnect Blackmagic's phone control app; the camera accepts one BLE controller at a time.
  • An electronically controllable lens/adapter with its AF switch enabled, or the tested PDMOVIE motor with a geared manual lens. Electronic-lens tracking has been exercised with the Sigma/Metabones and Canon/Metabones combinations above; results from one setup may not transfer unchanged.

The code recognises Pocket Cinema Camera … and Blackmagic … Camera video device names; this is not a claim that every such model supports the tested focus behaviour.

Other ways to run

The installer creates .venv, installs the pinned Python dependencies, and builds the Dock app and background service.

For a terminal-only start, use .venv/bin/python dashboard.py or double-click Launch Dashboard.command. For an interface demo without hardware, run .venv/bin/python dashboard.py --sim while the service is stopped (both use port 8765).

The service log is at ~/Library/Logs/BM4K Autofocus.log.

Lens profiles and compatibility

The included profiles/64x-sigma-dc-18-35-1-7-hsm.json contains a measured focus-position-to-distance curve for the tested Sigma 18–35/Metabones setup. An experimental Canon 24–105 profile is also included. Both curves are lens-specific. If your camera reports a different lens name or adapter variant, the app creates a separate profile instead of silently reusing one of these curves.

On first use, precise tracking has no local learning data yet. With a face visible, it uses the camera's one-shot AF to establish an initial focus point, then learns how face size and focal length relate to the camera's reported focus distance. As it runs, it also adjusts for focus-scale drift and records sharpness references. These numeric adjustments are saved locally in focus_model.json for each lens; they can vary with the subject, distance, camera setup and shooting conditions such as lighting. The live file is excluded from Git so each user can keep learning without committing personal session data. No face images are stored in it.

We have published the numeric observations from our Sigma and Canon sessions in examples/learned-electronic-focus.example.json. Users with the same camera, lens and adapter can inspect those as possible starting data; the app does not apply them automatically because the current shift and sharpness references can be wrong for another physical setup or subject. A coding agent can help merge a matching lens entry into a local focus_model.json after checking the lens identifier. The app then continues to refine the model during use. Always keep a copy of the local file before replacing it.

The motor's observed points are published separately in examples/learned-pdmovie-motor.example.json. They document the tested Samyang and Veydra setup, but do not copy them into settings.json as a ready-made calibration: the raw motor coordinates change with gear engagement and the physical stop calibration. Use the dashboard's Calibrate this lens action for a new mounting and let the app learn its own points. These examples contain numeric positions and sharpness values, not images or LiDAR readings.

For a different lens, the precise mode attempts a one-time sweep of the focus range (about a minute) and writes a new profiles/<lens>.json. During that sweep the focus travels across its range. If the camera does not report distance for that lens, the profile is marked no_distance and tracking falls back to the camera's centre-frame AF. This path has not been validated on other lenses: inspect the result and treat it as experimental, rather than reusing the Sigma curve. Please share lens model, adapter, camera model, whether focus distance is reported, and a tested profile via an issue or pull request. Do not include focus_model.json, traces or images of people.

BMPCC 6K support is a possible community extension, not a tested feature. Device naming, USB video, BLE commands and lens feedback need real hardware validation.

Troubleshooting

  • Camera video missing: confirm USB-C data connection and webcam mode. The app never falls back to the MacBook/iPhone camera. It may restart itself if the UVC open hangs; check the service log.
  • Bluetooth disconnected: check both Bluetooth switches, disconnect the phone controller, and reopen the app. If the service has retained a stale Bluetooth state, restart it from the dashboard or restart the service app.
  • Permissions missing: grant Camera and Bluetooth to BM4K Autofocus Service; rebuilding the app may trigger new macOS permission prompts.
  • Port 8765 in use: another copy may be running. Check with lsof -nP -iTCP:8765 -sTCP:LISTEN.
  • Installation fails on PyObjC: use Python 3.9–3.12 and upgrade pip in the venv: .venv/bin/python -m pip install --upgrade pip.

Project layout

Path Purpose
dashboard.py, web/ local control panel, WebSocket status and preview
autofocus.py, focusmodel.py, motor_autofocus.py, pdmovie_motor.py electronic-lens tracking, learned models and experimental PDMOVIE motor control
video.py, bmcc.py Blackmagic video capture and Apple Vision face detection
camera.py, camera_models.py, camera_format.py, camera_settings.py, protocol.py Bluetooth Camera Control link, camera selection, recording modes, settings and packet encoding
profiles/ measured lens profiles; Sigma is tested and Canon 24–105 is experimental
examples/, PDMOVIE_BLE_FINDINGS.md published numeric learning examples and motor interface observations
build_app.py, autostart.py, assets/ macOS Dock and service app builders
tests/ protocol, model and camera selection checks

Run the offline checks with .venv/bin/python tests/test_protocol.py, .venv/bin/python tests/test_camera_format.py, .venv/bin/python tests/test_camera_settings.py, .venv/bin/python tests/test_focusmodel.py, .venv/bin/python tests/test_video_devices.py, .venv/bin/python tests/test_equipment.py, .venv/bin/python tests/test_pdmovie_motor.py, .venv/bin/python tests/test_motor_autofocus.py, .venv/bin/python tests/test_manual_lens_profiles.py and .venv/bin/python tests/test_autofocus_seed.py. Hardware behaviour requires an actual camera and lens.

See CONTRIBUTING.md for lens test reports and privacy guidelines. Released under the MIT License.

Explore related projects

Loading…