Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for 720p (lower resolution) #3

Open
geerlingguy opened this issue Sep 30, 2020 · 6 comments
Open

Add option for 720p (lower resolution) #3

geerlingguy opened this issue Sep 30, 2020 · 6 comments

Comments

@geerlingguy
Copy link
Owner

geerlingguy commented Sep 30, 2020

Strangely, when I try getting 720p I just get a black screen:

Screen Shot 2020-09-30 at 4 07 47 PM

See config: e7a9850#diff-21c8dfbe329c77cb4e51518964c0f09a

The way it's set up it would allow 720p at the 'High' res on QuickTime Player's selection, and 1080p at the 'Maximum' res on the selection... but if I choose 720, it just shows a black frame :(

Screen Shot 2020-09-30 at 4 09 15 PM

@geerlingguy
Copy link
Owner Author

I've been thinking through it a bit wrong. It looks like the more important bits are in the actual uvc-gadget.c code. I'm going to have to do some more digging.

geerlingguy added a commit that referenced this issue Sep 30, 2020
@geerlingguy
Copy link
Owner Author

Well now...

It looks like if I default to 720p for the stream, it shows fine in 'High' but blacks out in 'Maximum'. And I can only choose one or the other. I tried adding -r0 -r1 and that seems to only allow one of the two to work still (with no error).

Here's when I started the camera in 'High':

streaming request (req 01 cs 01)
setting probe control, length = 26
streaming request (req 81 cs 01)
streaming request (req 01 cs 02)
setting commit control, length = 26
UVC: 2 buffers allocated.
V4L2: Starting video stream.
UVC: Starting video stream.

And maximum:

UVC: Stopping video stream.
streaming request (req 01 cs 01)
setting probe control, length = 26
streaming request (req 81 cs 01)
streaming request (req 01 cs 02)
setting commit control, length = 26
UVC: 2 buffers allocated.
V4L2: Starting video stream.
UVC: Starting video stream.
UVC: Stopping video stream.
streaming request (req 01 cs 01)
setting probe control, length = 26
streaming request (req 81 cs 01)
streaming request (req 01 cs 02)
setting commit control, length = 26
UVC: 2 buffers allocated.
V4L2: Starting video stream.
UVC: Starting video stream.

And back to 'High':

UVC: Stopping video stream.
streaming request (req 01 cs 01)
setting probe control, length = 26
streaming request (req 81 cs 01)
streaming request (req 01 cs 02)
setting commit control, length = 26
UVC: 2 buffers allocated.
V4L2: Starting video stream.
UVC: Starting video stream.
UVC: Stopping video stream.
streaming request (req 01 cs 01)
setting probe control, length = 26
streaming request (req 81 cs 01)
streaming request (req 01 cs 02)
setting commit control, length = 26
UVC: 2 buffers allocated.
V4L2: Starting video stream.
UVC: Starting video stream.

What I don't understand is how QuickTime Player's High/Maximum link up to the external device in any way. I thought it was just a toggle for whether to use H.264 (or 265?) or ProRes formats... but it seems to consistently only work with one of the formats.

@geerlingguy
Copy link
Owner Author

So for 1080p:

sudo /home/pi/uvc-gadget/uvc-gadget -f1 -s1 -r1 -u /dev/video1 -v /dev/video0^C

And for 720p:

sudo /home/pi/uvc-gadget/uvc-gadget -f1 -s1 -r0 -u /dev/video1 -v /dev/video0^C

I wish I could figure out what the 'High' vs. 'Maximum' selection did on QuickTime, because:

  • If I use r0 (720p) the webcam works on High but outputs a black frame on Maximum
  • If I use r1 (1080p) the webcam works on Maximum but outputs a black frame on High

I'm thinking that the device caps are being sent across due to the settings pushed out in multi-gadget.sh here: https://github.com/geerlingguy/uvc-gadget/blob/master/multi-gadget.sh#L28-L68

Those dirs, once created and in use, seem to not be able to be removed. So I might have to re-flash the Pi to switch to 720p-only mode...

@geerlingguy
Copy link
Owner Author

So, basically... if the device advertises 1080p and 720p (or I guess any lower res) via the files modified by the multi-gadget.sh script, then QuickTime will try to switch resolutions when it switches between High/Maximum.

If you only have 1080p, or only 720p, then QuickTime will keep the same resolution when switching between High/Maximum.

Good to know, though I would really like to be able to have the gadget switch from 720p on High to 1080p on Maximum—however, for now, I'm happy enough to just be able to set my Pi to 720p, which seems to have a lot fewer dropped frames on a Pi Zero, and is more than adequate for video conferencing or as a small camera overlay on a stream.

So I'll leave 720p as the default, but I'll leave this issue open as someday I might get some time to explore supporting the automatic resolution switching. That'd be nice.

@seanreynoldscs
Copy link

I ran this command and now the webcam no longer shows up on my Mac. Any ideas?
sudo /home/pi/uvc-gadget/uvc-gadget -f1 -s1 -r0 -u /dev/video1 -v /dev/video0

@seanreynoldscs
Copy link

okay I rebuilt my raspi (overkill I know)
and now when trying to run:
sudo /home/pi/uvc-gadget/uvc-gadget -f1 -s1 -r1 -u /dev/video1 -v /dev/video0
I get:
V4L2: Unable to set format Device or resource busy (16).

How do you shut off the video streaming so that I can adjust the resolution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants