1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00

avdevice/avfoundation: keep format and frame rate range paired

Formats with the same dimensions may expose different frame rates. The
selection loop previously updated selected_format for every size match but
kept selected_range from an earlier format. This could apply a range to a
format that does not support it and make device configuration fail.

Only update selected_format together with its matching range. Track a
size-only match separately so the muxed-device fallback remains unchanged.

Reported-by: MW-de <mw-de@noreply.code.ffmpeg.org>
Suggested-by: MW-de <mw-de@noreply.code.ffmpeg.org>
Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/22694
Signed-off-by: iSold Leo <s@qwqlog.com>
This commit is contained in:
iSold Leo
2026-08-03 19:43:47 +08:00
committed by Romain Beauxis
parent d20bae84e0
commit d65fd5581d

View File

@@ -394,6 +394,7 @@ static int configure_video_device(AVFormatContext *s, AVCaptureDevice *video_dev
double framerate = av_q2d(ctx->framerate);
NSObject *range = nil;
NSObject *format = nil;
NSObject *matching_size_format = nil;
NSObject *selected_range = nil;
NSObject *selected_format = nil;
@@ -411,13 +412,14 @@ static int configure_video_device(AVFormatContext *s, AVCaptureDevice *video_dev
if ((ctx->width == 0 && ctx->height == 0) ||
(dimensions.width == ctx->width && dimensions.height == ctx->height)) {
selected_format = format;
matching_size_format = format;
for (range in [format valueForKey:@"videoSupportedFrameRateRanges"]) {
double max_framerate;
[[range valueForKey:@"maxFrameRate"] getValue:&max_framerate];
if (fabs (framerate - max_framerate) < 0.01) {
selected_format = format;
selected_range = range;
break;
}
@@ -425,7 +427,7 @@ static int configure_video_device(AVFormatContext *s, AVCaptureDevice *video_dev
}
}
if (!selected_format) {
if (!matching_size_format) {
av_log(s, AV_LOG_ERROR, "Selected video size (%dx%d) is not supported by the device.\n",
ctx->width, ctx->height);
goto unsupported_format;
@@ -435,6 +437,7 @@ static int configure_video_device(AVFormatContext *s, AVCaptureDevice *video_dev
av_log(s, AV_LOG_ERROR, "Selected framerate (%f) is not supported by the device.\n",
framerate);
if (ctx->video_is_muxed) {
selected_format = matching_size_format;
av_log(s, AV_LOG_ERROR, "Falling back to default.\n");
} else {
goto unsupported_format;