GithubHelp home page GithubHelp logo

puhitaku / mtplvcap Goto Github PK

View Code? Open in Web Editor NEW
246.0 8.0 17.0 7.47 MB

Nikon to USB Webcam. Supports older models that Nikon WU does not. Windows/macOS/Linux. No HDMI capture dongle is needed. Ask me on Twitter @puhitaku

Home Page: https://twitter.com/puhitaku

License: Other

Go 95.48% Python 1.03% Makefile 0.02% HTML 3.46%
nikon webcam nikon-camera

mtplvcap's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mtplvcap's Issues

Not Working with D7100

Hi,

I'm using a go binary built in my PC on Ubuntu 20.04. But getting the following error.

`[0000] INFO usb: found: 8087:0a2b
[0000] INFO usb: found: 04b0:0430
[0000] WARN mtp: detected more than 1 device, opening the first device: 8087:0a2b
[0000] ERROR mtp: fatal error LIBUSB_ERROR_IO; closing connection.
[0000] FATAL mtp: failed to detect MTP devices: could not open 8087:0a2b: mtp: no MTP extensions in ''

Kindly let me know if there is a way to resolve this.

Not working with D5200 / Windows build is broken

The original problem

WARN lv: frameCaptor: failed to parseMovieTimeRemain

It should be fixed as of cc6755e

Windows build is broken

Related: #22

  • mtplvcap.exe suddenly stops working right after looking up the device
  • Windows build looks broken and can't reproduce a working binary
  • Difference of build dependencies is suspicious
    • To reject a case that the breaking change is from a diff of code, I have to git reset to the time of the last successful build (1.1.3) and build it on CI, then see if it works

D750 support

Hi, I have tried with a D750 on linux but did not succeed in opening the shutter.

[0000]  INFO usb: found: 04b0:0437
[0000]  INFO main: started
[0000] DEBUG lv: manufacturer = NIKON, product = NIKON DSC D750, serialnumber = XXXXX
[0000] DEBUG lv: model didn't match, falling back to the generic model%!(EXTRA string=)
[0001] DEBUG lv: current recording media: card
[0001] DEBUG lv: the recording media is the card. Switching it to the SDRAM.
[0004] ERROR mtp: fatal error LIBUSB_ERROR_TIMEOUT; closing connection.
[0007]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open

The -backend-go gets rid of the USB error timeout but does not open the shutter either. Let me know if you would like some more info or to try something else.

How to get other qualities?

Hi, I'm using Nikon D5100 and everything works fine but there is a problem. mtplvcap only captures 640x424 video quality. I wanted to see how I can get other qualities like full-HD as well.

Doesn't work with Z f

  • Macbook Pro (2021, 14-inch)
  • macOS Ventura 13.6
$ sudo mtplvcap
[0000]  INFO usb: found: 04b0:0453
[0000]  INFO usb: detected macOS Ventura or newer: trying to detach the kernel driver
[0000]  INFO main: started
[0003] ERROR lv: failed to start live view (InvalidStatus). Investigating the reason...
[0003]  WARN lv: workerLV: failed to start live view, reason: (empty)
[0004] ERROR lv: failed to start live view (InvalidStatus). Investigating the reason...
[0004]  WARN lv: workerLV: failed to start live view, reason: (empty)

[Report] Nikon Z6 ii high(er) resolution works

Ubuntu 20.04
Nikon Z6 ii
Built mtplvcap from source (main - 7cfaf84)

$ ./mtplvcap -max-resolution
[0000]  INFO usb: found: 04b0:044c
[0000]  INFO usb: found: 8087:07dc
[0000]  WARN mtp: detected more than 1 device
[0000]  INFO mtp: opening the detected Nikon DSLR: 04b0:044c
[0000]  INFO main: started
[0001]  INFO lv: getting available resolutions
[0001]  INFO lv: available resolutions (higher is larger): [1 2 3]
[0001]  INFO lv: automatically use the largest choice: 3

In http://localhost:42839/, the resolution is 1024x576.

Feature request: Send stream to stdout

I am using your program with OBS as per instruction as a webcam, but using OBS for just this is an overkill.
Would it be possible to send the same stream you are sending to websocket to the STDOUT? In this case, on Linux I would be able to pipe it to a virtual video device directly.

Error on Nikon D3100

Hi, recieving the following error on Nikon D3100


[0000]  INFO usb: found: 04b0:0427
[0000] ERROR mtp: fatal error LIBUSB_ERROR_IO; closing connection.
[0000] FATAL main: failed to detect MTP devices: could not open 04b0:0427: mtp: no MTP extensions in ''

OS Ubuntu 20.04

Z5 successfully working

My Nikon Z5 successfully connects using mtplvcap-1.3.1 on Gentoo (5.10.27 kernel). The OBS packaging doesn't support building the browser source component until the still-officially-unreleased 27.0.1 EBUILD, and even then I can only get Firefox to recognize the (built-in, not plugin) virtual camera and not the Chromium-based Brave. Trying to manually set the F-stop throws ERROR lv: HandleControl: failed to set f-number: failed to set f-number: AccessDenied, and I don't know if I tested the ISO slider, but the other controls all work.

SIGSEV with binaries and own build

Thanks for providing the tool!

I tried the 1.5.0 binary and a local build from latest master. With both I get a SIGSEGV error when running the tool after granting it permissions via Security & Privacy. I'm using macOS 11.5.2 with an i7.

$ ./mtplvcap -debug server

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x7fff20338c9e]

runtime stack:
runtime: unexpected return pc for runtime.sigpanic called from 0x7fff20338c9e
stack: frame={sp:0x7ffeefbff508, fp:0x7ffeefbff558} stack=[0x7ffeefb805b8,0x7ffeefbff610)

wrong name of libusb dependency

in the readme.md, the dependency should be libusb-1.0-0 and libusb-1.0-0-dev instead of libusb-1.0.0 and libusb-1.0.0-dev
(hyphen instead of dot near the end)
it was the reason for the tool not working in my case
im submitting a pull request to rectify this

D7000で以下メッセージが出て動作しませんでした。

環境:macOSX Catalina 10.15.7
Nikon D7000 / TypeCアダプタ経由のUSB接続

git cloneでコンパイルして利用

@mbp15:~ $ ./mtplvcap -debug server
[0000] INFO usb: found: 04b0:0428
[0000] INFO usb: found: 0bda:8153
[0000] WARN mtp: detected more than 1 device, opening the first device: 04b0:0428
[0000] INFO main: started
[0000] DEBUG lv: manufacturer = NIKON, product = NIKON DSC D7000, serialnumber = 00000xxxxxxxxxx
[0000] DEBUG lv: model didn't match, falling back to the generic model%!(EXTRA string=)
[0001] DEBUG lv: current recording media: SDRAM
[0001] ERROR lv: failed to start live view (InvalidStatus). Investigating the reason...
[0001] WARN lv: workerLV: failed to start live view, reason: the release mode is mirror-up

mtplvcap for mac M1 not working

Hi:
Im trying to use my Nikon d5000 in my new mac mini M1.
When I get to the part of installing the dowloaded zip mtplvcap_macos_amd64.zip I get the attached message.
Also I can't access http://localhost:42839, which would be the camera controller.

I would very appreciate your help since i have not knowledge about coding.

Cheers.

/Users/paolusmac/Downloads/mtplvcap_macos_amd64/mtplvcap ; exit;
paolusmac@Paoluss-Mac-mini ~ % /Users/paolusmac/Downloads/mtplvcap_macos_amd64/mtplvcap ; exit;
dyld: Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
Referenced from: /Users/paolusmac/Downloads/mtplvcap_macos_amd64/mtplvcap
Reason: image not found
zsh: abort /Users/paolusmac/Downloads/mtplvcap_macos_amd64/mtplvcap
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

Camera model matching doesn't work for Z cameras

Hello,

First of all, I'd like to confirm that Z9 does indeed work. I'm happy to provide you any data you want/need from it.
Secondly, I think I've found a small bug which doesn't affect anything.

In nikon.go there is a map where keys are camera names and values are their description.
For Z9 the product name from USB is NIKON DSC Z 9, for Z 7II the product name is NIKON DSC Z 7_2
So a slight change needed to make mtplvcap detect the model properly:


diff --git a/mtp/nikon.go b/mtp/nikon.go
index 2b24716..572aa66 100644
--- a/mtp/nikon.go
+++ b/mtp/nikon.go
@@ -182,12 +182,12 @@ var models = ModelMap{
                HeaderSize:     384,
                ResolutionType: ResolutionType8,
        },
-       "Z7II": {
+       "7_2": {
                Name:           "Z7II",
                HeaderSize:     384,
                ResolutionType: ResolutionType8,
        },
-       "Z9": {
+       "9": {
                Name:           "Z9",
                HeaderSize:     384,
                ResolutionType: ResolutionType8,

I guess, the same change will be needed for some other newer models (like z6, z7, z6ii, z5, z50, zfc). But at the same time their parameters match the default so no real benefit of doing this.
It may also worth reimplementing camera model detection and may be rely on some ID.
Sadly, I have zero experience with usb or mtp so I'm pretty useless at proving patches here.

D7000 wrong resolution reported

For D7000 the resolution reported is 4,928 x 3,264 (picture resolution) while actual live view is 640 × 424.
Is this the only possible resolution?
Camera is capable of 1,920 × 1,080 (24p) in video.

D7100 image is really dark ISO is 0

image is really dark and when you go on the web-browser the ISO is set to 0.

When you change it, it basically crashes and nothing else works from that point on, have to kill the camera to quit the application.

Not working with D300

I tried to use it on my D300, but it did not work.

[0000]  INFO usb: found: 04b0:041a
[0000]  INFO main: started  
[0002]  WARN lv: workerLV: failed to start live view: the camera is not ready  
[0003]  WARN lv: frameCaptor: failed to decode header  
  • I heard the shutter open.
  • localhost:42839/view was not displayed.
  • After changing the F-stop on localhost:42839 and disconnecting the connection, I checked the settings of the main unit and found that the value had been changed.

The environment in which it was run is as follows.

OS : Ubuntu 20.10
Version : v1.2.0

Find the way to enable the higher resolution on all models

Prop 0xD1AC is the only way I know to change the resolution. Some models support reading/writing this. Some models only support reading. And others do not support neither reading nor writing.

According to a Nikon guy, there are many differences in MTP commands and props between DSLRs. Their public SDK may give me something interesting, but it's licensed under a proprietary agreement that is considered not to be compatible with GPL.

I'm having conversation with them and I may implement this feature after they released it licensed under a OSI-approved licenses.

Does not work with D5100

After installation on Mac OS 10.15, the camera is not recognized by OBS or Skype.

`[0000] INFO usb: found: 04b0:0429
[0000] INFO usb: found: 0a12:0001
[0000] WARN mtp: detected more than 1 device, opening the first device: 04b0:0429
[0000] INFO main: started

# ./mtplvcap -debug server
zsh: no such file or directory: ./mtplvcap`

workerLV: failed to start live view: the camera is not ready

I am trying to get mtplvcap working with my Nikon D5000 camera. It is connected to my desktop via USB, 0x0423 its ID (I have more than one MTP devices connected, therefore I specify that explicitly). Whenever and wherever I tried to run the software (I have Windows 10 and Arch Linux in dual-boot) I have one and the same error:

➜ mtplvcap -product-id 0x0423
[0000]  INFO usb: found: 04b0:0423
[0000]  INFO main: started
[0002]  WARN lv: workerLV: failed to start live view: the camera is not ready

I do not have any possible interfering software running or any other drivers for my D5000 on both OS and still I continue to getting one and the same error.
I see that D5000 is in the list of supported cameras, just wandering what am I missing...

P.S. at the moment of [0000] INFO main: started I clearly hear camera shutter click and see that the diaphragm goes from completely opened to ~half closed position, and then I receive [0002] WARN lv: workerLV: failed to start live view: the camera is not ready

Z50 hi-res report

Hi,
I have a Nikon Z50 with the latest firmware. I just wanted to report that I'm able to use my Z50 with mtplvcap -max-resolution and get 1024x576 video at about 47-50 fps.

I was surprised to achieve this - especially since the Z50 only has a micro USB connector (which I'm assuming is USB 2.x speeds).

Sorry if this is not the right place for this report, but I wanted to pass along the feedback. Thank you for this project!

Unable to use OBS virtual camera

Hello there! First of all, thank you for creating such an awesome piece of software!

I'm having some trouble getting the OBS virtual camera to work on platforms like Google Meet and Zoom. I have a Nikon D5200. Here's my current config:

image
image
image
image

Any ideas on what the issue could be here? Thanks again!

Doesn't build

I try build from source, but output many error.
but can't finish.
How to fix?
Sorry write poor English...

ricotyan:mtplvcap ricotan_aikatsu$ go version
go version go1.18.3 darwin/amd64

ricotyan:mtplvcap ricotan_aikatsu$ neofetch 
                    'c.          [email protected] 
                 ,xNMM.          ------------------------------ 
               .OMMMMo           OS: macOS High Sierra 10.13.6 17G66 x86_64 
               OMMM0,            Host: MacBookPro11,4 
     .;loddo:' loolloddol;.      Kernel: 17.7.0 
   cKMMMMMMMMMMNWMMMMMMMMMM0:    Uptime: 19 hours, 57 mins 
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.    Packages: 154 (brew) 
 XMMMMMMMMMMMMMMMMMMMMMMMX.      Shell: bash 3.2.57 
;MMMMMMMMMMMMMMMMMMMMMMMM:       Resolution: 1920x1200 
:MMMMMMMMMMMMMMMMMMMMMMMM:       DE: Aqua 
.MMMMMMMMMMMMMMMMMMMMMMMMX.      WM: Quartz Compositor 
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.    WM Theme: Blue (Light) 
 .XMMMMMMMMMMMMMMMMMMMMMMMMMMk   Terminal: Apple_Terminal 
  .XMMMMMMMMMMMMMMMMMMMMMMMMK.   Terminal Font: SFMono-Regular 
    kMMMMMMMMMMMMMMMMMMMMMMd     CPU: Intel i7-4980HQ (8) @ 2.80GHz 
     ;KMMMMMMMWXXWMMMMMMMk.      GPU: Intel Iris Pro 
       .cooc,.    .,coo:.        Memory: 10864MiB / 16384MiB 

                                                         
                                                         



ricotyan:mtplvcap ricotan_aikatsu$ CGO_CFLAGS='-Wno-deprecated-declarations' go build .
go: downloading github.com/google/gousb v2.1.0+incompatible
go: downloading golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
go: downloading github.com/sirupsen/logrus v1.6.0
go: downloading github.com/x-cray/logrus-prefixed-formatter v0.5.2
go: downloading github.com/gorilla/websocket v1.4.2
go: downloading github.com/hanwen/usb v0.0.0-20141217151552-69aee4530ac7
go: downloading github.com/paulbellamy/ratecounter v0.2.0
go: downloading go.uber.org/atomic v1.6.0
go: downloading github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
go: downloading golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: downloading golang.org/x/sys v0.0.0-20200519105757-fe76b779f299
go: downloading github.com/mattn/go-colorable v0.1.7
go: downloading github.com/mattn/go-isatty v0.0.12
# golang.org/x/sys/unix
../go/pkg/mod/golang.org/x/[email protected]/unix/syscall_darwin.1_13.go:29:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.1_13.go:27:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.1_13.go:40:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:28:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:43:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:59:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:75:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:90:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:105:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:121:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:121:3: too many errors
# pkg-config --cflags  -- libusb-1.0
Package libusb-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libusb-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libusb-1.0' found
pkg-config: exit status 1
# pkg-config --cflags  -- libusb-1.0
Package libusb-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libusb-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libusb-1.0' found
pkg-config: exit status 1
ricotyan:mtplvcap ricotan_aikatsu$ brew install libusb
Warning: You are using macOS 10.13.
We (and Apple) do not provide support for this old version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
old version.

==> Downloading https://github.com/libusb/libusb/releases/download/v1.0.26/libusb-1.0.26.tar.bz2
==> Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e65be/15120676/ebba8859-25d1-4a37-b80f-cf18699d2bdd?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220620%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Da
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/libusb/1.0.26
==> make install
🍺  /usr/local/Cellar/libusb/1.0.26: 22 files, 465.3KB, built in 14 seconds
==> Running `brew cleanup libusb`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
ricotyan:mtplvcap ricotan_aikatsu$ CGO_CFLAGS='-Wno-deprecated-declarations' go build .
# golang.org/x/sys/unix
../go/pkg/mod/golang.org/x/[email protected]/unix/syscall_darwin.1_13.go:29:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.1_13.go:27:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.1_13.go:40:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:28:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:43:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:59:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:75:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:90:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:105:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:121:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_amd64.go:121:3: too many errors

fatal error LIBUSB_ERROR_TIMEOUT; closing connection

Hey, I'm trying to get this working on debian with latest build from master but I'm getting this error:

ERROR mtp: fatal error LIBUSB_ERROR_TIMEOUT; closing connection

I have D5600, have you seen similar issues? What would be a good way to approach the issue?

I tried extending ModelMap by copying D5500 to D5600 config; still nothing.

fatal error LIBUSB_ERROR_TIMEOUT; closing connection

D5500, that works fine with Nikon's own software (Webcam Utility) other than the obnoxious black borders all around the frame, which is why I wanted to try this.

brew install libusb went fine.

Running the binary (directly from Terminal) does not prompt for permission in any way, and nothing shows up in the Security & Privacy system prefs pane.

All I get output is:

[0000]  INFO usb: found: 04b0:0438
[0000]  INFO main: started
[0004] ERROR mtp: fatal error LIBUSB_ERROR_TIMEOUT; closing connection.
[0007]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0007]  WARN lv: workerLV: failed to start live view: LIBUSB_ERROR_TIMEOUT
[0007]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0008]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0008]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0009]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open

…and that repeats endlessly.

macOS 11.4 (20F71). ("Big Sur")

D800E does work!!!

開発者様

お世話になります。

D800EおよびD7000について
最下部掲載の環境にて無事に動作しましたので、
ご報告いたします。

以前試したD800E → HDMI → キャプチャーカード(Elgato, Cam Link 4K) → Win10
の構成では動作しなかったので諦めていました。ところが、
このソフトを使わせて頂いたことで、全て解決しました。

本当に、感動いたしました。

誠に感謝申し上げます。

動作が成功した環境

OS

macOS Big Sur 11.0.1 --> 11.1

Camera

  • D800E
  • D7000

App

  • OBS 26.1.2(include macOS Virtual Camera)
  • Zoom 5.4.9(59931.0110)
  • Firefox 84.0.2

Does not work on macOS Ventura 13.1

Failing part

The current master branch fails to open the DSLR prompting the following error:

$ ./mtplvcap
[0000]  INFO usb: found: 04b0:0431
[0000] ERROR mtp: fatal error LIBUSB_ERROR_NOT_FOUND; closing connection.
[0000] FATAL main: failed to detect MTP devices: could not open 04b0:0431: mtp: no MTP extensions in ''

With a patch to fix the lack of error handling (which is a shame,) like the following:

@@ -120,10 +125,14 @@ func (d *DeviceDirect) Open() error {
                log.USB.Debugf("open, err: %v", err)
        }
        if err != nil {
-               return err
+               return fmt.Errorf("failed to open: %w", err)
+       }
+
+       err = d.claim()
+       if err != nil {
+               return fmt.Errorf("failed to claim: %w", err)
        }

-       d.claim()
        if d.ifaceDescr.InterfaceStringIndex == 0 {
                // Some of the win8phones have no interface field.
                info := DeviceInfo{}

The actual error in claim function shows up:

$ ./mtplvcap
[0000]  INFO usb: found: 04b0:0431
[0000] FATAL main: failed to detect MTP devices: could not open 04b0:0431: failed to claim: LIBUSB_ERROR_ACCESS

Root cause

macOS Ventura has some changes related to MTP devices. For example,

Many people say that it is due to a kernel driver that occupies the device. So I added a call to libusb_detach_kernel_driver:

@@ -93,7 +93,12 @@ func (d *DeviceDirect) claim() error {
                return fmt.Errorf("mtp: claim: device not open")
        }

-       err := d.h.ClaimInterface(d.ifaceDescr.InterfaceNumber)
+       err := d.h.DetachKernelDriver(d.ifaceDescr.InterfaceNumber)
+       if err != nil {
+               return err
+       }
+
+       err = d.h.ClaimInterface(d.ifaceDescr.InterfaceNumber)
        if d.Debug.USB {
                log.USB.Debugf("claimInterface 0x%x, err: %v", d.ifaceDescr.InterfaceNumber, err)
        }

It worked as I expected, but only with the superuser privilege.

Mysterious though, even after detaching the kernel driver, mtplvcap without super privilege has no access to the device.

# With the privilege, it works without a problem

$ sudo ./mtplvcap
Password:
[0000]  INFO usb: found: 04b0:0431
[0000]  INFO main: started
^C[0003]  INFO main: caught signal: interrupt
[0004] ERROR main: interrupt

# Without the privilege, it finds no MTP device.

: mtplvcap $ ./mtplvcap
[0000] FATAL main: failed to detect MTP devices: no MTP devices found

Temporary solution

The only way to make it work is to apply the patch above and run mtplvcap as a superuser.

Not working with D700

From YasukiKishi:

  • D700を電源ON⇒mtplvcap.exe起動したらシャッターは開く。
  • localhost:42839でISO,F値,Focus制御はできるが、Width,Height,Frame rateの情報は取れていない、プレビューも絵が映らない
  • localhost:42839/viewも表示できない
[0000]  INFO usb: found: 04b0:0422
[0000]  INFO usb: found: 0cf3:e303
[0000]  WARN mtp: detected more than 1 device, opening the first device: 04b0:0422
[0000]  INFO main: started
[0002]  WARN lv: workerLV: failed to start live view: the camera is not ready
[0003]  WARN lv: frameCaptor: failed to decode header

-max-resolution not working on D3500

Hello, just tried -max-resolution with my D3500 and it displays 2 resolutions, but when it tries to use the resolution 2 nothings appears then lisbusb closes the connection

[0000] INFO usb: found: 04b0:0445
[0000] INFO usb: found: 8087:0aaa
[0000] WARN mtp: detected more than 1 device
[0000] INFO mtp: opening the detected Nikon DSLR: 04b0:0445
[0000] INFO main: started
[0001] INFO lv: getting available resolutions
[0001] INFO lv: available resolutions (higher is larger): [1 2]
[0001] INFO lv: automatically use the largest choice: 2
[0004] ERROR mtp: fatal error LIBUSB_ERROR_TIMEOUT; closing connection.
[0007] WARN lv: workerLV: failed to start live view: LIBUSB_ERROR_TIMEOUT
[0007] WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0007] WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open

[macos]pkg-config: exec: "pkg-config": executable file not found in $PATH

Hi,

When following macOS 2.b.4 CGO_CFLAGS='-Wno-deprecated-declarations' go build ., the following error was displayed:

➜  mtplvcap git:(master) CGO_CFLAGS='-Wno-deprecated-declarations' go build .
go build github.com/hanwen/usb:
# pkg-config --cflags  -- libusb-1.0
pkg-config: exec: "pkg-config": executable file not found in $PATH
go build github.com/google/gousb:
# pkg-config --cflags  -- libusb-1.0
pkg-config: exec: "pkg-config": executable file not found in $PATH

adding pkg-config to macOS 2.b.1 fixed the issue

process doesn't stop when camera is disconnected

When camera is not connected and I start mtplvcap it is exiting, but if I just disconnect the camera while capturing it continue and just sending errors continuously:

[0054]  WARN lv: workerLV: failed to get live view status: LIBUSB_ERROR_NO_DEVICE
[0054]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0055]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0055]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0056]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0056]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0057]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0057]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0058]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0058]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0059]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0059]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0060]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0060]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0061]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0061]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0062]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0062]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0063]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0063]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0064]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0064]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0065]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0065]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0066]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0066]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0067]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0067]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0068]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0068]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open
[0069]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0069]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open

support?

can this support coolpix L24?

Sometimes SIGINT does not close the shutter

Successful case:

[0000]  INFO usb: found: 04b0:0431
[0000]  INFO main: started
[0002]  WARN lv: frameCaptor: failed to obtain an image: DeviceBusy
[0007]  INFO http: GET /view 127.0.0.1:63112
^C[1776]  INFO signal: caught signal: interrupt
[1776] ERROR mtp: fatal error transaction ID mismatch got 275bf want 275c0; closing connection.
[1776] ERROR main: interrupt

failed to detect MTP devices: could not open 04b0:0448

Hello,
Thank you for the tool!

I encounter an error after compilation

./mtplvcap
[0000] INFO usb: found: 13d3:3563
[0000] INFO usb: found: 04b0:0448
[0000] WARN mtp: detected more than 1 device
[0000] INFO mtp: opening the detected Nikon DSLR: 04b0:0448
[0000] FATAL main: failed to detect MTP devices: could not open 04b0:0448: failed to claim: failed to claim: LIBUSB_ERROR_BUSY

I use Ubuntu 22.04, Nikon Z5

Any tips how to overcome this issue?

NOT work on Win10 Pro(Oct./2020)

開発者様

お世話になります。

macOS Big Sur 11.1ではD800E/D7000ともに無事動いたので
味をしめてWin10機2台で試しました。

しかし、全く起動しなかったのでご報告いたします。

症状

Win機 1台目(Dell PRECISION TOWER 7910)

前提: OSのゴミが溜まってるのか、少々状態が不安定

  1. driverのinstallは無事に完了し、デバイスマネージャでも確認済み
  2. Win用ビルド済みの実行ファイルを開いた瞬間に落ちる。

Win機 2台目(Panasonic Let's Note CF-SZ5)

前提: つい最近、OSはクリーンインストール済み

  1. driverのinstallは無事に完了し、デバイスマネージャでも確認済み
  2. Win用ビルド済みの実行ファイルを開いたら、以下のlogまで出して落ちる
    [0000] INFO usb: found: 04b0:042e
    [0000] INFO usb: found: 8087:0a2b
    [0000] WARN mtp: detected more than 1 device, opening the first device: 04b0:042e

試した環境

OS

Win10 Pro(Oct./2020) ver. 20H2
OS build 19042.746

Camera

  • D800E
  • D7000

App

  • Win用ビルド済みの実行ファイル
  • OBS 26.1.1-64bit Win
  • Zoom 5.4.6(59296.1207)
  • Firefox 84.0.2

ERROR mtp: fatal error LIBUSB_ERROR_TIMEOUT on D810

Hi, i have encountered a similar issue on my D810 as some Users before me.

./mtplvcap -debug server
[0000]  INFO usb: found: 04b0:0436
[0000]  INFO main: started
[0000] DEBUG lv: manufacturer = NIKON, product = NIKON DSC D810, serialnumber = 0000002009398
[0000] DEBUG lv: model didn't match, falling back to the generic model 
[0003] ERROR mtp: fatal error LIBUSB_ERROR_TIMEOUT; closing connection.
[0006]  WARN lv: frameCaptor: failed to obtain an image: LIBUSB_ERROR_TIMEOUT
[0006]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0006]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0007]  WARN lv: workerLV: failed to get live view status: mtp: cannot run operation GetDevicePropValue, device is not open
[0007]  WARN lv: frameCaptor: failed to obtain an image: mtp: cannot run operation MTP_WMPPD_PlaylistObjectPref, device is not open

The shutter stays closed and the mirror up mode doesn't do anything either.

Higher Resolution?

Hello,

First of all, the solution is working great with my D3300. It was simple to connect and provides noticeably less latency that using a capture card. My one question: Is it possible to achieve higher resolutions using this solution? Perhaps 720p or even the native 1080p for this camera?

Thanks

Not working with D3000

Mac Big Sur 11.0.1にて検証いたしました

状況

  • D3000を電源ON => ./mtplvcap
  • localhost:42839は表示されるが、各種設定に反応せず、プレビューも絵が映らない
  • localhost:42839/viewも表示できない

ログ

こちらでなにかわかりますでしょうか?

mtplvcap_macos_amd64 % ./mtplvcap
[0000]  INFO usb: found: 04b0:0424
[0000]  INFO main: started
[0000]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
[0001]  WARN lv: workerLV: failed to get live view status: DevicePropNotSupported
[0001]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
[0002]  WARN lv: workerLV: failed to get live view status: DevicePropNotSupported
[0002]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
[0002]  INFO http: GET / 127.0.0.1:51368
[0002]  INFO http: GET /assets/popper.min.js 127.0.0.1:51374
[0002]  INFO http: GET /assets/bootstrap4-toggle.min.css 127.0.0.1:51370
[0002]  INFO http: GET /assets/bootstrap4-toggle.min.js 127.0.0.1:51378
[0002]  INFO http: GET /assets/bootstrap.min.js 127.0.0.1:51376
[0002]  INFO http: GET /assets/jquery-3.5.1.slim.min.js 127.0.0.1:51372
[0002]  INFO http: GET /assets/bootstrap.min.css 127.0.0.1:51368
[0002]  INFO http: GET /favicon.ico 127.0.0.1:51368
[0003]  WARN lv: workerLV: failed to get live view status: DevicePropNotSupported
[0003]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
[0004]  WARN lv: workerLV: failed to get live view status: DevicePropNotSupported
[0004]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
[0004] ERROR lv: HandleControl: failed to set ISO: failed to set ISO: AccessDenied
[0004] ERROR lv: HandleControl: failed to set ISO: failed to set ISO: AccessDenied
[0005]  WARN lv: workerLV: failed to get live view status: DevicePropNotSupported
[0005] ERROR lv: HandleControl: failed to set ISO: failed to set ISO: AccessDenied
[0005] ERROR lv: HandleControl: failed to set ISO: failed to set ISO: AccessDenied
[0005]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
[0006]  WARN lv: workerLV: failed to get live view status: DevicePropNotSupported
[0006] ERROR lv: HandleControl: failed to set f-number: failed to set f-number: failed to stop live view: OperationNotSupported
[0006]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
[0006] ERROR lv: HandleControl: failed to set f-number: failed to set f-number: failed to stop live view: OperationNotSupported
[0007]  WARN lv: workerLV: failed to get live view status: DevicePropNotSupported
[0007] ERROR lv: HandleControl: failed to set f-number: failed to set f-number: failed to stop live view: OperationNotSupported
[0007]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
[0008]  WARN lv: workerLV: failed to get live view status: DevicePropNotSupported
[0008]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
^C[0009]  INFO signal: caught signal: interrupt
[0009] ERROR main: interrupt
mtplvcap_macos_amd64 % ./mtplvcap --debug server
[0000]  INFO usb: found: 04b0:0424
[0000]  INFO main: started
[0000] DEBUG lv: manufacturer = NIKON, product = NIKON DSC D3000, serialnumber = 000002033316
[0000] DEBUG lv: model matched: D3
[0000]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
[0001]  WARN lv: workerLV: failed to get live view status: DevicePropNotSupported
[0001]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
[0002]  WARN lv: workerLV: failed to get live view status: DevicePropNotSupported
[0002]  WARN lv: frameCaptor: failed to obtain an image: OperationNotSupported
[0003]  WARN lv: workerLV: failed to get live view status: DevicePropNotSupported

dyld: Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib on Apple Silicon computer

Commands I ran through:

unzip mtplvcap_macos_amd64
cd mtplvcap_macos_amd64
./mtplvcap

After I accept the binary file to be used in Security Settings panel, I get:

dyld: Library not loaded: /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
  Referenced from: [removed-path-but-this-is-in-my-downloads-directory]
  Reason: image not found
zsh: abort      ./mtplvcap

Also tried to build myself using source:

 CGO_CFLAGS='-Wno-deprecated-declarations' go build .

Where I get:

# pkg-config --cflags  -- libusb-1.0
Package libusb-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libusb-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libusb-1.0' found
pkg-config: exit status 1
# pkg-config --cflags  -- libusb-1.0
Package libusb-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libusb-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libusb-1.0' found
pkg-config: exit status 1

I see that brew installled version 1.0.24 of libusb on my computer, so I believe that's the problem. How would I go about fixing it?

D500 worked

D500

kind ver
model D500(firmware 1.3.0)
OS Debian sid(test day is 03/27/2021)
mtplvcap 1.2.0
obs 26.1.2-290-ga52012e8c(building with browser source)
zoom 5.6.13558.0321

Nikon Z6 - No MTP Extensions in ''

Not entirely sure what is going on.

Followed the Linux instructions and tried both pre-built and self-built approaches of the software.

Encountering the following error.

>> /mtplvcap -debug server
[0000]  INFO usb: found: 04b0:0443
[0000] ERROR mtp: fatal error LIBUSB_ERROR_IO; closing connection.
[0000] FATAL mtp: failed to detect MTP devices: could not open 04b0:0443: mtp: no MTP extensions in ''
>> lsusb
Bus 009 Device 006: ID 04b0:0443 Nikon Corp. 

Any help appreciated!

"-max-resolution" not workig with some models

Related: #44

Switching to XGA does not work with mtplvcap. I also tested this with ptpwebcam on a Mac which actually worked.

I uploaded the camera info from ptpwebcam as camera.txt:
camera.txt

This is from the log of mtplvcap

[0001]  INFO lv: available resolutions (higher is larger): [1 2 3]
[0001]  INFO lv: automatically use the largest choice: 3
[0004]  WARN lv: failed to change the image resolution (%!s(MISSING)); if it affects capturing frames, consider disabling `-max-resolution

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.