danielpaulus / quicktime_video_hack

Record iOS device audio and video
MIT License
537 stars 113 forks source link

`qvh devices` returned empty list & qvh reported weird serial number #50

Closed wchensc closed 4 years ago

wchensc commented 4 years ago

What I got weird serial number: FM78484028HJ2KVAJ+EDZ\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000

When I ran qvh devices it returned empty list. I ran quicktime player and made the video source as my phone and I can see the screen shows what I did on the phone.

Env MacOx majave 10.14.6 iphone X ios 10.0.1

nanoscopic commented 4 years ago

This seems to be a bug in in the underlying gousb code. All quicktime_video_hack does is directly call Device.SerialNumber()

It calls this: https://godoc.org/github.com/google/gousb#Device.SerialNumber

That function is defined here: https://godoc.org/github.com/google/gousb#Device.SerialNumber

That in turn calls getStringDescriptor: https://github.com/google/gousb/blob/593cfb67e9ce5b359ac6830e3408abc4637a12af/device.go#L221

That calls getStringDesc: https://github.com/google/gousb/blob/9ad54830f48186bf46677a3e4aec6667b1462ebb/libusb.go#L385

That calls libusb_get_string_descriptor_ascii from libusb

That function is defined here: https://github.com/libusb/libusb/blob/14a302a2f55cb2e619158854f94845f2ca2c8214/libusb/descriptor.c#L1060

I don't see anything particularly wrong in any of those functions offhand. Somewhere in that series of function calls there is a bug that is causing length to be ignored and garbage after the serial number to be included as part of the serial number.

Do you see the same thing if you use ios_video_pull -devices from https://github.com/nanoscopic/ios_video_pull ?

wchensc commented 4 years ago

ios_video_pull -devices also returned empty results.

nanoscopic commented 4 years ago

See https://github.com/nanoscopic/ios_video_pull/blob/master/main.go#L477 That function loops through all the interfaces on a USB device. It seems that your device is not returning any interfaces with the class "gousb.ClassVendorSpec".

You should craft a loop similar to above and dump out all the Class/SubClass combinations that are exposed on your device.

wchensc commented 4 years ago

I think I mentioned it before. Even if I use lsusb directly, it was not able to find my device.

Btw I reclone the ios_video_pull repo and tried to build the repo but got: make: *** No rule to make targetvendor/github.com/danielpaulus/quicktime_video_hack/screencapture/usbadapter.go', needed by ios_video_pull'. Stop.

nanoscopic commented 4 years ago

@wchensc What platform are you attempting to use the code on? All of the code I have developed is intended to work only on MacOS. There is no lsusb on mac by default.

If you are trying to use stf_ios_support or ios_video_pull or any of those components on anything except MacOS then I am not myself interested in helping you. That is not the purpose of the open source I have created for STF and IOS.

As far this repo, Daniel Paulus has created it to be multi-platform so perhaps he can be of assistance if you are trying to use something other than MacOS.

I have installed brew installed lsusb on a mac with ISO devices plugged in; they appear fine. Your device is hosed if it doesn't. You are wasting both of our time trying to use a device that doesn't even appear on the USB bus correctly.

wchensc commented 4 years ago

I am using MacOS, as you said using MacOS is the purpose.

And I already mentioned before that gousb didn't find the device and then you told me to create this issue here. I think there might be some misunderstanding of the purpose of this github issue.

Here is the conversation snippet:

Me:

I tried enabling the quicktime with my phone. This time i saw the Video Interface Available, but the device still could not be found.
...
The gousb is not able to detect the device.

You:

Based on your log messages it looks like the qvh code is failing to recognize the udid of your device.
( this line: {"level":"info","msg":"Got serialFM78484028HJ2KVAJ+EDZ\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","time":"2020-05-13T11:11:35-07:00"} )
I'd reccomend opening a Github issue with upstream QVH:
https://github.com/danielpaulus/quicktime_video_hack/

It was my fault that I didn't point that out earlier.

So I tried to plug the same device to another macmini instead of my Macbook Pro and lsusb found the device successfully. I am not sure what was wrong with my Mac.

wchensc commented 4 years ago

I pulled the latest code and reran. I got "configuration id 6 not found in the descriptor of the device. Available config ids: [1 2 3 4 5]","time":"2020-05-20T14:34:09-07:00" in gousb.

I changed it to 5 it seemed to successfully get the information but it ended up with:

{"level":"info","msg":"QT Config is active: vid=05ac,pid=12a8,bus=20,addr=16,config=5","time":"2020-05-20T14:35:09-07:00"}
{"level":"info","msg":"Got QT iface:vid=05ac,pid=12a8,bus=20,addr=16,config=5,if=2,alt=0","time":"2020-05-20T14:35:09-07:00"}
{"level":"info","msg":"Inbound Bulk: ep #6 IN (address 0x86) bulk [512 bytes]","time":"2020-05-20T14:35:09-07:00"}
{"level":"info","msg":"Outbound Bulk: ep #5 OUT (address 0x05) bulk [512 bytes]","time":"2020-05-20T14:35:09-07:00"}
{"level":"info","msg":"Device '3cb4a6cf84863fc25d3d2f7d0346e22b34c2aa3e' ready to stream ( click 'Settings-Developer-Reset Media Services' if nothing happens )","time":"2020-05-20T14:35:09-07:00"}
{"level":"info","msg":"AudioVideo-Stream has started","time":"2020-05-20T14:35:09-07:00"}
2020/05/20 14:35:20 handle_events: error: libusb: interrupted [code -10]
2020/05/20 14:35:38 handle_events: error: libusb: interrupted [code -10]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x42efa72]

Changing to 4 will get rid of all error msg but the device was not showing on UI.

nanoscopic commented 4 years ago

@wchensc That is good progress. Configuration 6 isn't available until the device is "activated". Just run stf_ios_support/bin/ios_video_pull -enable and that will turn the config 6 on. You can see it is activate / check it is active by running ios_video_pull -devices

wchensc commented 4 years ago

The config 6 is available now.

{"level":"info","msg":"Opened device","time":"2020-05-28T13:50:44-07:00"}
{"level":"info","msg":"Device '490dc4f7bad4023d109721325b237fac6c624461' ready to stream ( click 'Settings-Developer-Reset Media Services' if nothing happens )","time":"2020-05-28T13:50:44-07:00"}
{"level":"info","msg":"Opened device","time":"2020-05-28T13:50:47-07:00"}
{"level":"info","msg":"Device '490dc4f7bad4023d109721325b237fac6c624461' ready to stream ( click 'Settings-Developer-Reset Media Services' if nothing happens )","time":"2020-05-28T13:50:47-07:00"}
2020/05/28 13:51:17 handle_events: error: libusb: interrupted [code -10]

The issue is inside of libusb. Do you know how I can get the logs there so that I can debug. Or is there anything that you can think of might result in the problem?

nanoscopic commented 4 years ago

@wchensc I haven't seen the issue you are describing with either any of the machines I have tried it on nor with any of the phones I have tested it with.

The "libusb: interrupted" error is irrelevant and of no consequence. It is output lots by the code when it is "working properly". It would be nice if it didn't occur but that isn't likely to be the source or even related to why you don't get video output.

I am not clear at this point what issue you are pursuing or raising in this ticket. As titled and described at the top of the ticket this one is to discuss the situation where you get a wierd serial number reported, but you just posted code showing a normal serial number.

You'll need to be clear about what is happening for me to be of any assistance.

Some various questions:

  1. Does qvh work to record a mp4 video from a device for you when using the "record" option?
  2. When you say "the issue is inside of libusb" what issue are you talking about? If not the one described by this ticket at the top please open a new ticket in the repo of the thing that seems to have some issue.
  3. In the error you included above "invalid memory address or nil pointer dereference" please post the backtrace that tells the stack and lines of code where the issue occurred. You left that part out.
  4. When attempting to use qvh; have you tried running it with the activate option first, then running record? Does that work for you?
wchensc commented 4 years ago

Thanks, closing this issue.