puhitaku / mtplvcap

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
https://twitter.com/puhitaku
Other
251 stars 17 forks source link

"-max-resolution" not workig with some models #56

Closed maxammann closed 2 years ago

maxammann commented 2 years ago

Related: https://github.com/puhitaku/mtplvcap/issues/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
maxammann commented 2 years ago

In fact I found out what the problem is :)

On the Z6, the datatype is u8:

    payload := struct {
        Resolution uint8
    }{
        Resolution: uint8(3),
    }
maxammann commented 2 years ago

POC: https://github.com/puhitaku/mtplvcap/commit/2f455e1608eb2fad955bfd760312053ab34e205d

puhitaku commented 2 years ago

Many thanks for the report and POC 👍 I'll merge your changes somehow, like adding a quirk flag ;) I leave here opened until then.

maxammann commented 2 years ago

Are you sure this is a quirk? With which Nikons did you test the 64bit value?

puhitaku commented 2 years ago

D500, D850, and D7500 want 64bit value and I confirmed it works. If the newer models incl. Z6 and the brothers want 8bit, it's not a quirk specific to Z6 and I'll add a new value like ResolutionValueType in the mtp.ModelMap struct.

(Extra story: I confirmed the max resolution feature in a camera store with permission from a clerk and I found that it doesn't work with Z6 and similar models. I didn't have a courage to ask clerk for a permission to debug my code in the store so I left there 😅)

maxammann commented 2 years ago

D500, D850, and D7500 want 64bit value and I confirmed it works. If the newer models incl. Z6 and the brothers want 8bit, it's not a quirk specific to Z6 and I'll add a new value like ResolutionValueType in the mtp.ModelMap struct.

(Extra story: I confirmed the max resolution feature in a camera store with permission from a clerk and I found that it doesn't work with Z6 and similar models. I didn't have a courage to ask clerk for a permission to debug my code in the store so I left there 😅)

Haha, nice! Do you know that you can get the documentation from nikon for all cameras? :) Im not sure whether one is allowed to use them though.

puhitaku commented 2 years ago

Do you know that you can get the documentation from nikon

That's what I'm negotiating with Nikon for. Here is the story. I'm asking a Nikon guy to re-release the SDK under an OSI-approved license.

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.

puhitaku commented 2 years ago

Sorry for being inactive, The fix is merged in #57 . mtplvcap now transmits an uint8 value for the newer models incl. Z6.

maxammann commented 2 years ago

No worries :) thank you for your project!

Will test next week

fedegratti commented 2 years ago

Hi @puhitaku I can confirm that this doesn't work on D3500:

image

maybe #57 fixes it?

Thank you for this project, I love it!

puhitaku commented 2 years ago

Thanks for the report fedegratti-san, I suspect that all Nikon needs uint8 (the fix introduced in #57) in the end so I'm going to test it in a week or so. Please wait for a while and I'll mention you.

ria8651 commented 2 years ago

I get exactly the same log as fedegratti with a D3400.

When using master I get:

Screen Shot 2022-03-12 at 7 46 35 PM

Awesome project thanks :)

puhitaku commented 2 years ago

Thank you everyone, now I identified the bug in changing the resolution and it is due to my untested change (Sorry for that! I have no new DSLRs capable of higher resolutions), so I fixed it now in #59 after a brief test in near camera shop.

Interestingly, the internal model name is different from what I expected e.g. Z7 II returns NIKON DSC Z 7_2 as its model name. And D3400 also differs too (its model name is NIKON DSC D3400 according to it while I expected "D3400").

fedegratti commented 2 years ago

Hi @puhitaku, thank you so much for your support!

I've just tested and it still not working on D3500:

image

I hope the above image helps. Also, if you need me to do some testing on my camera, we can do chat about it.

Lastly, do you have a place for donations? I love your work and I would like to give you something!

Cheers.

puhitaku commented 2 years ago

That's because the resolution value type is "falling back" (as you see in the log) to uint64 I guess and I added a tweak to use uint8 by default.

@fedegratti Could you pull the branch fix/resolution and give it a try again?

do you have a place for donations? I love your work and I would like to give you something!

Thank you very much! Donation is very appreciated. The top page of mtplvcap and my GitHub profile page have a link to GitHub Sponsors and Patreon.

fedegratti commented 2 years ago

@fedegratti Could you pull the branch fix/resolution and give it a try again?

@puhitaku same issue. Is there a way to log more info? Maybe I can add more logs in the core.

puhitaku commented 2 years ago

Argh, I temporarily can't think of what to do next ... I should borrow a D3500 (or other model that causes the "closing connection").

maxammann commented 2 years ago

Argh, I temporarily can't think of what to do next ... I should borrow a D3500 (or other model that causes the "closing connection").

We could also take a look at the specification. Im pretty sure thats legal.

maxammann commented 2 years ago

According to some other project the D3500 is not capable of higher resolutions: https://github.com/dognotdog/ptpwebcam/blob/9f138716eaf1d14a3505f57b71480ab8577150e5/CAMERAS.md#aps-c--dx

keeandamok commented 2 years ago

for the d3300 im getting a similar error to the d3400

Screen Shot 2022-04-20 at 1 57 41 AM
fedegratti commented 2 years ago

Hi @puhitaku, were you able to find a workaround for this issue?

puhitaku commented 2 years ago

@maxammann

According to some other project the D3500 is not capable of higher resolutions

If its max is 640x480, it actually is. But they described the resolution pair with parens. I'm not sure what it means.

@fedegratti Unfortunately, no :P

Is there a way to log more info?

mtplvcap is not so verbose even when all logging options are enabled because I preferred to debug it with an interactive debugger. I think I should improve and increase the log... At present, I'm pretty not sure how to remedy this and looking for a D3500 body.

puhitaku commented 2 years ago

Sorry for neglecting here. And thanks for kind donations.

puhitaku commented 2 years ago

@maxammann It's been a while, Z6 is confirmed to accept high resolutions according to a comment in #59 . The fixed version v1.5.1 is released. Thanks for providing me a POC!

JobLeonard commented 1 year ago

Despite the issue being closed I assume this is the best topic to give resolution feedback for untested models, is that correct?

I just tried this out for my Z fc. It works, max resolution is 1024x680. So a higher resolution is available, but it doesn't seem to have the full range the camera should be able to support.

image
puhitaku commented 1 year ago

@JobLeonard Hi Job, I appreciate your feedback. So glad to see that Z fc supports high-res!

I assume this is the best topic to give resolution feedback for untested models, is that correct?

Yes, commenting here and creating a new issue are the choices, and "it worked" things will come here since no further discussion is needed in general.

it doesn't seem to have the full range

It should be possible to transmit high-res frames like 1920x1080 at 30fps, but Nikon seems not to give LV more than a preview purpose.

JobLeonard commented 1 year ago

Ah, so they distinguish the live view from their own "webcam" support? That explains it :)

Luckily 1024x680 is more than enough for my purposes, the image is so clean it's probably better than most people's HD webcams anyway ;)

And as a Linux user, thanks for writing this amazing piece of software!