diff --git a/src/video.cpp b/src/video.cpp index 02f996df565..2c3a8b3b938 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -1929,21 +1929,28 @@ namespace video { return nullptr; } + // may be downgraded below if the device can't deliver HDR (e.g. NvFBC's CUDA path is NV12/YUV444P only) + bool dynamicRange = config.dynamicRange; + if (config.chromaSamplingType == 1) { if (!video_format[encoder_t::YUV444]) { BOOST_LOG(error) << video_format.name << ": YUV 4:4:4 not supported"sv; return nullptr; } - if (config.dynamicRange && !video_format[encoder_t::DYNAMIC_RANGE_YUV444]) { - BOOST_LOG(error) << video_format.name << ": YUV 4:4:4 dynamic range not supported"sv; - return nullptr; + if (dynamicRange && !video_format[encoder_t::DYNAMIC_RANGE_YUV444]) { + BOOST_LOG(warning) << video_format.name << ": YUV 4:4:4 dynamic range not supported, falling back to SDR"sv; + dynamicRange = false; + encode_device->colorspace.colorspace = colorspace_e::rec709; + encode_device->colorspace.bit_depth = 8; } } else { - if (config.dynamicRange && !video_format[encoder_t::DYNAMIC_RANGE]) { - BOOST_LOG(error) << video_format.name << ": dynamic range not supported"sv; - return nullptr; + if (dynamicRange && !video_format[encoder_t::DYNAMIC_RANGE]) { + BOOST_LOG(warning) << video_format.name << ": dynamic range not supported, falling back to SDR"sv; + dynamicRange = false; + encode_device->colorspace.colorspace = colorspace_e::rec709; + encode_device->colorspace.bit_depth = 8; } } @@ -1987,7 +1994,7 @@ namespace video { // HEVC uses the same RExt profile for both 8 and 10 bit YUV 4:4:4 encoding ctx->profile = AV_PROFILE_HEVC_REXT; } else { - ctx->profile = config.dynamicRange ? AV_PROFILE_HEVC_MAIN_10 : AV_PROFILE_HEVC_MAIN; + ctx->profile = dynamicRange ? AV_PROFILE_HEVC_MAIN_10 : AV_PROFILE_HEVC_MAIN; } break; @@ -2147,11 +2154,11 @@ namespace video { for (auto &option : video_format.common_options) { handle_option(option); } - for (auto &option : (config.dynamicRange ? video_format.hdr_options : video_format.sdr_options)) { + for (auto &option : (dynamicRange ? video_format.hdr_options : video_format.sdr_options)) { handle_option(option); } if (config.chromaSamplingType == 1) { - for (auto &option : (config.dynamicRange ? video_format.hdr444_options : video_format.sdr444_options)) { + for (auto &option : (dynamicRange ? video_format.hdr444_options : video_format.sdr444_options)) { handle_option(option); } }