Repository navigation
mac-avcapture: Use list-based format selector - #10895
Conversation
PatTheMav
left a comment
There was a problem hiding this comment.
Left some code-specific comments, overall I'd like to see more discussion about:
- Presentation of the formats in the dropdown (@Warchamp7 got some ideas there?)
- How to "upgrade" existing source configurations
af5e538 to
9ef9d69
Compare
|
Couple misc changes:
Secondly, added a migration routine in Hopefully this should be in a pretty good state now. Was intending to squash at the end, just let know if you want me to squash whenever. |
9719b24 to
f5e0f4f
Compare
This comment was marked as resolved.
This comment was marked as resolved.
829f71e to
57b315a
Compare
|
Per discussions out of band, I am adding one last feature to this in a separate commit; if the user selects a format that does not support their previously configured frame rate, we will fall back to an appropriate FPS supported by the format based on OBS's configured output frame rate. This fallback frame rate is determined by the new function After sitting on it, I think that the benefits are large enough that the addition of this functionality is merited. Namely, it seems like selecting a navigating to a format in the properties window should try to offer immediate feedback to help the user select a format, rather than requiring fiddling with the frame rate selector on each selection just to get a visual preview. Hitting cancel in the window is always a reliable "bail out" to return to the previous committed configuration. While it is a relatively small addition, it's nontrivial enough that I am adding it in a separate commit so it can be looked at, and I can squash the commits later. I will request re-reviews for the two approvals here since it seems appropriate. |
PatTheMav
left a comment
There was a problem hiding this comment.
Works as advertised apart from the code-style issues I commented on separately.
I'm not really a fan of the aspect ratio in the format drop-down and exposing all the frame rate ranges in it: With some devices I tested with this list becomes a big bunch of textual noise, so the usefulness of the information is drowned out by that.
Personally I'd rather have something that is simple and low-effort to parse for the user with a straight-forward and consistent behaviour. The existence of a bespoke frame rate selector makes exposing the ranges in the first dropdown redundant.
@Warchamp7 what do you think? I've posted some screenshots off-thread that display the "noise" I mention.
77b75a7 to
f196378
Compare
|
Added a second commit to address some visual noise when there are a great many FPS ranges present on a format. The approach taken in the second commit simplifies the FPS ranges description if there are more than ten ranges, showing the minimum and maximum FPS in the array of ranges and the number of ranges. This can happen if a card advertises many discrete values in the form of ranges, i.e. 30-30, 45-45, 60-60. This scenario is currently disambiguated from a "genuine range" with a parenthetical indicating the number of ranges. So for example a format advertising 60 ranges between 1 and 120 fps would show "1 - 120 FPS (60 values)". While a genuine FPS range between 1-120 (i.e. any frame rate between 1-120 is supported) would show just "1 - 120 FPS". This is not perfect, but it seems necessary to handle this edge case if a format has, for example, 60 FPS ranges, each representing discrete integers between 1 and 60. |
645bd36 to
d422d79
Compare
PatTheMav
left a comment
There was a problem hiding this comment.
Works fine with all devices available to me.
|
My final request for this is gonna be to change the discrete FPS listings to be from low to high, so that it's consistent with FPS ranges being low to high. |
|
Done. I went ahead and squashed all commits, so I reproduced the change below; it is just a one liner to enumerate the sorted ranges in reverse order when specifically generating the description. I also documented that it uses ascending order. Lastly I fixed a tiny issue where, for the "over 10 ranges" case, we were using the ranges from the API (presumably-sorted) rather than guaranteed-sorted, when getting the minimum and maximum rate. ---
plugins/mac-avcapture/OBSAVCapture.h | 2 +-
plugins/mac-avcapture/OBSAVCapture.m | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/plugins/mac-avcapture/OBSAVCapture.h b/plugins/mac-avcapture/OBSAVCapture.h
index 3f1a4216e..b0468d4fd 100644
--- a/plugins/mac-avcapture/OBSAVCapture.h
+++ b/plugins/mac-avcapture/OBSAVCapture.h
@@ -264,7 +264,7 @@ static const UInt32 kMaxFrameRateRangesInDescription = 10;
+ (FourCharCode)fourCharCodeFromFormat:(OBSAVCaptureVideoFormat)format withRange:(enum video_range_type)videoRange;
-/// Generates a string describing an array of frame rate ranges.
+/// Generates a string describing an array of frame rate ranges. The frame rate ranges are described in ascending order.
/// - Parameter ranges: [NSArray](https://developer.apple.com/documentation/foundation/nsarray?language=objc) of [AVFrameRateRange](https://developer.apple.com/documentation/avfoundation/avframeraterange?language=objc), such as might be provided by an `AVCaptureDeviceFormat` instance's [videoSupportedFrameRateRanges](https://developer.apple.com/documentation/avfoundation/avcapturedeviceformat/1387592-videosupportedframerateranges) property.
/// - Returns: A new [NSString](https://developer.apple.com/documentation/foundation/nsstring?language=objc) instance that describes the frame rate ranges.
+ (NSString *)frameRateDescription:(NSArray<AVFrameRateRange *> *)ranges;
diff --git a/plugins/mac-avcapture/OBSAVCapture.m b/plugins/mac-avcapture/OBSAVCapture.m
index 64118173a..1dab839b4 100644
--- a/plugins/mac-avcapture/OBSAVCapture.m
+++ b/plugins/mac-avcapture/OBSAVCapture.m
@@ -1053,7 +1053,7 @@ + (NSString *)frameRateDescription:(NSArray<AVFrameRateRange *> *)ranges
}];
NSString *frameRateDescription;
NSMutableArray *frameRateDescriptions = [[NSMutableArray alloc] initWithCapacity:ranges.count];
- for (AVFrameRateRange *range in sortedRangesDescending) {
+ for (AVFrameRateRange *range in [sortedRangesDescending reverseObjectEnumerator]) {
double minFrameRate = round(range.minFrameRate * 100) / 100;
double maxFrameRate = round(range.maxFrameRate * 100) / 100;
if (minFrameRate == maxFrameRate) {
@@ -1074,8 +1074,9 @@ + (NSString *)frameRateDescription:(NSArray<AVFrameRateRange *> *)ranges
frameRateDescription = [frameRateDescriptions componentsJoinedByString:@", "];
frameRateDescription = [frameRateDescription stringByAppendingString:@" FPS"];
} else if (frameRateDescriptions.count > kMaxFrameRateRangesInDescription) {
- frameRateDescription = [NSString stringWithFormat:@"%.0f-%.0f FPS (%lu values)", ranges.lastObject.minFrameRate,
- ranges.firstObject.maxFrameRate, ranges.count];
+ frameRateDescription =
+ [NSString stringWithFormat:@"%.0f-%.0f FPS (%lu values)", sortedRangesDescending.lastObject.minFrameRate,
+ sortedRangesDescending.firstObject.maxFrameRate, sortedRangesDescending.count];
}
return frameRateDescription;
}
-- |
Description
Updates the properties window for macOS
mac-avcapturesources to use a unified list-based format selector when in the non-preset mode. Also adds a contextual warning in the properties window to show when a device has macOS system effects active.The frame rate selector is retained, so that we can continue to have explicit control over the device frame rate. The list selectors for resolution, color space, pixel format and video range, however, have all been consolidated inside the single format selector.
Motivation and Context
#9344 provided a much-needed update to the Video Capture Device source on macOS and added a lower-latency Capture Card Device source. A number of factors, however, have conspired to make the new version of the source harder to use, for both novice and adept users:
This PR aims to simplify and improve the UI for the source while also reducing the complexity of the property selection code.
Additionally, the new effects warning in the properties window should help to alleviate some user confusion. On macOS, enabling an effect such as Studio Light or Portrait mode for one video input will often enable them on all inputs (filed as FB13302833). Users are often confused to see webcam effects on e.g. capture card inputs. With this PR, the source properties window displays a warning for active system effects, which should make this issue more apparent.
How Has This Been Tested?
Tested locally on an M1 Max machine running the macOS Sequoia beta with all video capture devices on hand, including the built-in webcam, Continuity Camera from an iPhone, a virtual camera, and a single capture card from a popular brand, to ensure both OBS source types remained in good working order.
Types of changes
Checklist: