Open iphydf opened 4 years ago
@iphydf can you PR your changes? I don't have any OSX system and won't be able to look into this.
The only change I could PR is the info.plist one, but that one only solves the problem for some users. The other part is asking for video permissions, and I'm doubtful that my solution was correct. It's likely that Qt internally calls the same "request permissions" functions, but for some reason doesn't, and then can't open the device. I tried to work around that by asking for permission myself (in qtox code) in the avfoundation thread, but even following that, Qt can't open the device:
[00:01:57.990 UTC] video/camerasource.cpp:272 : Debug: Opening device "DJH73820JF3GJKD11" subscriptions: 1
[AVFoundation input device @ 0x7ff508738b80] Video device not found
[00:01:57.990 UTC] video/camerasource.cpp:285 : Warning: Failed to open device!
Maybe we're passing the wrong identifier for camerasource to open the video device?
Actually, never mind about that Qt opening device thing. We're using ffmpeg for that, and the [AVFoundation ...]
message comes from there. (Also: https://ffmpeg.org/ffmpeg-devices.html#avfoundation and https://lists.ffmpeg.org/pipermail/ffmpeg-user/2015-October/028764.html).
@iphydf if the plist thing fixes it even only for some users I'd call that progress. I suppose this is needed anyway to make video work for all users, or not?
Probably yes.
@iphydf have you done the pull request? I've experienced this issue today... Have you managed to make it work for the desktop? Can you detail how to modify avfoundation.mm? thks ;)
I managed to get myself a setup where qtox doesn't work with one of the cameras (a virtual one), but does detect it. ffmpeg itself does both detect and work with it: I can record videos from the device with ffmpeg (the exact same ffmpeg I built qtox with). Can anyone with ffmpeg knowledge assist in debugging this?
Thks for the update. I'll explain my use case: I was trying to screen share to a group's meeting, but I would only get a black screen. I've tried utox also, and I've managed to get my webcam's feed, but no screen capture was available. I've tried qtox clients on both VMs (Win7 and Ubuntu 16.04) and I could get access to screen capture. Thus, I figured out it could only be a permissions issue on OSX. I've cloned the repo, and I was trying to see if your suggestions could fix the issue. Can you guide me through the process?
It's most likely not a permissions problem, because your camera is detected. In order to detect cameras, you need permissions already. Otherwise it'll show you an empty list.
Only in utox I can have access to the camera. On qtox, unfortunately, not. :( On both VMs with qtox I can also; but not on native Mac OS. Like you said previously, qtox does not ask for camera permission, while utox does. For all these reasons, I've figured out it should be the permissions issue...
That does sound like permission then. I'll look into what utox is doing.
@iphydf thks for taking the time to take a look at it :)
Once https://github.com/qTox/qTox/pull/6092 is merged, try if that fixes the problem for you. I know it doesn't fix the problem everywhere yet, but permissions might not be the problem for some of them.
@iphydf I'll check it once it's available and I'll let you know ;) Anyway, thks for taking the time to try to solve this issue :D
@ElectroQuanta can you try running the following:
ffplay -f avfoundation -list_devices true -i ""
If this lists your camera correctly, try:
ffplay -f avfoundation -i Face
(assuming your camera is called something like "FaceTime Camera".
@iphydf, here are the results:
ffplay -f avfoundation -list_devices true -i ""
[AVFoundation input device @ 0xXXXXXXXX] AVFoundation video devices:
[AVFoundation input device @ 0xXXXXXXXX] [0] FaceTime HD Camera
[AVFoundation input device @ 0xXXXXXXXX] [1] Capture screen 0
[AVFoundation input device @ 0xXXXXXXXX] [2] Capture screen 1
[AVFoundation input device @ 0xXXXXXXXX] AVFoundation audio devices:
[AVFoundation input device @ 0xXXXXXXXX] [0] Built-in Microphone
: Input/output error
ffplay -f avfoundation -i Face
: failed due to unsupported framerate (see 3)
[avfoundation @ 0xXXXXXXXXXXXX] Selected framerate (29.970030) is not supported by the device.
[avfoundation @ 0xXXXXXXXXXXXX] Supported modes:
[avfoundation @ 0xXXXXXXXXXXXX] 1280x720@[1.000000 30.000000]fps
Last message repeated 2 times
[avfoundation @ 0xXXXXXXXXXXXX] 640x480@[1.000000 30.000000]fps
Last message repeated 2 times
[avfoundation @ 0xXXXXXXXXXXXX] 320x240@[1.000000 30.000000]fps
Last message repeated 2 times
Face: Input/output error
ffplay -f avfoundation -i Face -framerate 30
: It opened up the camera feed and everything looked OK
[avfoundation @ 0xXXXXXXXXXXXX] Selected pixel format (yuv420p) is not supported by the input device.
[avfoundation @ 0xXXXXXXXXXXXX] Supported pixel formats:
[avfoundation @ 0xXXXXXXXXXXXX] uyvy422
[avfoundation @ 0xXXXXXXXXXXXX] yuyv422
[avfoundation @ 0xXXXXXXXXXXXX] nv12
[avfoundation @ 0xXXXXXXXXXXXX] 0rgb
[avfoundation @ 0xXXXXXXXXXXXX] bgr0
[avfoundation @ 0xXXXXXXXXXXXX] Overriding selected pixel format to use uyvy422 instead.
Duration: N/A, start: 45364.137800, bitrate: N/A
Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 320x240, 30 tbr, 1000k tbn, 1000k tbc
ffplay -f avfoundation -i Capture
: It opened up a recursive window snapshoting (i guess) one of my external monitors.
[[AVFoundation input device @ 0x7fcd9b709340] Configuration of video device failed, falling back to default.
[avfoundation @ 0xXXXXXXXXXXXX] Selected pixel format (yuv420p) is not supported by the input device.
[avfoundation @ 0xXXXXXXXXXXXX] Supported pixel formats:
[avfoundation @ 0xXXXXXXXXXXXX] uyvy422
[avfoundation @ 0xXXXXXXXXXXXX] yuyv422
[avfoundation @ 0xXXXXXXXXXXXX] nv12
[avfoundation @ 0xXXXXXXXXXXXX] 0rgb
[avfoundation @ 0xXXXXXXXXXXXX] bgr0
[avfoundation @ 0xXXXXXXXXXXXX] Overriding selected pixel format to use uyvy422 instead.
[avfoundation @ 0xXXXXXXXXXXXX] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, avfoundation, from 'Capture':
Duration: N/A, start: 45751.906667, bitrate: N/A
Stream #0:0: Video: rawvideo (UYVY / 0x59565955), uyvy422, 1920x1080, 1000k tbr, 1000k tbn, 1000k tbc
@ElectroQuanta excellent, thanks! I think this is the solution then: we need to explicitly set the frame rate somewhere using the ffmpeg API.
@sudden6 @anthonybilinski this is probably easy, but I don't know how to use the ffmpeg API. Maybe one of you knows?
AFAICT we already explicitely set the framerate here: https://github.com/qTox/qTox/blob/master/src/video/cameradevice.cpp#L222
Maybe the query for available frame rates is broken?
@iphydf , I've checked the nightly build after the commit #6092 was merged (see https://github.com/qTox/qTox/issues/6056#issuecomment-614871590). Now, when I open the Audio/Video Tab it requested the Audio access, which was granted. However, it still did not request Camera acess. Moreover, I cannot access nor preview any of the video devices: This is strange because I saw your commit, and camera permission was there... Maybe it is insufficient?
I have a report from a user on MacOS 10.15.4 where the camera works without issues. (qTox v1.17.2)
@sudden6 thks for taking the time to look into it, and for providing a new software version. I've downloaded v1.17.2 today and I'm running MacOS 10.15.4. Status:
Additionally, I've tried to manually add the permissions to System Preferences, but qTox does not show under camera or screen sharing pane, and Apple does not allow any other method for this (to my knowledge).
I know that this is just a permissions issue, because I've had the same issue with OBS today, but I could add the permissions required, because they show up under the relevant preferences pane.
So, could you pinpoint me to any hint? Maybe, the user that reported success can provide some insights :)
The user didn't do anything special AFAIK, just downloaded and ran the v1.17.2 release. Maybe there are traces left of an earlier qTox version that cause problems?
Maybe they ran their system in some mode where permissions are not that strictly enforced? (I have no idea if that's a thing on MacOS)
@sudden6, I've deleted all traces left from earlier versions, uninstall, reboot and then install again. However, the trouble still persists :(
I've found out a interesting suggestion to give permissions to the terminal, which will run as proxy for the program (see here). It did not work either.
Lastly, I've run this for debugging (see here):
open /Applications/qtox.app/Contents/MacOS/qtox --args --picture
And the result is:
I've debugged the application by experimenting with the UI, and I've found that:
Critical: Trying to select best mode from empty modes list
[23:43:43.765 UTC] video/cameradevice.cpp:160 : Warning: VideoMode could be invalid!
[AVFoundation input device @ 0x7f9c34f77dc0] Unable to parse option value "0x0" as image size
[AVFoundation input device @ 0x7f9c34f77dc0] Error setting option video_size to value 0x0.
[23:43:43.765 UTC] video/camerasource.cpp:284 : Warning: Failed to open device!
I think this may be related to what @iphydf was trying to check here, but I'm not sure :/ Or maybe it's just the permissions issues, preventing the devices from being accessed...
I just installed qTox v1.17.2 (up to date), commit hash: 465d82606813439ee14425f7462903bb39f2da30, toxcore version 0.2.11, Qt version 5.14.2.
I have 2 cameras on my early 2011 MacBook Pro, running macOS 10.13.6.
The system report shows: FaceTime HD Camera (Display):
Model ID: UVC Camera VendorID_1452 ProductID_4370 Unique ID: 0x4...
FaceTime HD Camera (Built-in):
Model ID: UVC Camera VendorID_1452 ProductID_34057 Unique ID: 0xf...
and when I go to select a video device in qTox, I see I can select:
None FaceTime HD Camera (Display) FaceTime HD Camera (Built-In) Capture screen 0 Capture screen 1
and no matter which FaceTime camera I select, I get the one on my display, not the one built-in to my MacBook.
Brief Description
OS: OS X qTox version: master Commit hash: master (of right now) toxcore: 0.2.11 Qt: 5.14.1 …
Reproducible: Always (on some systems)
Steps to reproduce
Observed Behavior
You can see the list of cameras, including Facetime HD, but selecting it shows nothing. There is also no dialog asking for camera permissions. Audio permissions are requested, and audio works.
Expected Behavior
Camera permissions should be asked for, and after granting them, you should see yourself in the camera.
Additional Info
https://en.it1352.com/article/7dc6f8b2cec94587a221dbbf871f4dea.html <- I tried some of this code in avfoundation.mm, and got a bit further. I at least got the camera permission request.
I also added this to info.plist, which made everything work for some but not all OSX systems I tested this on: