> Am 22.04.2022 um 18:52 schrieb Thilo Borgmann <thilo.borgm...@mail.de>: > >
> For that version I get: > > libavcodec/videotoolboxenc.c:1153:39: error: use of undeclared identifier > 'kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality' > > kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality, > ^ > > Should require some OSX version dependency via #if'ery somewhere sane. Like > #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 > > or similar. If I understand the code correctly, it seems to me to be bettter to add kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality to the compat_keys struct. And digging through the SDK headers I’ve found that this property is available for h264 and ProRes encoders too. But since the SDK states that this property defaults to FALSE for h264 and hevc and to TRUE for ProRes I didn’t add it to the COMMON_OPTIONS but to each encoder options, because I didn’t want to make a regression to the ProRes or enabling it by default for h264 and hevc. Hope that’s ok. Here’s the resulting patch Regards Simone Signed-off-by: Simone Karin Lehmann <sim...@lisanet.de <mailto:sim...@lisanet.de>> --- libavcodec/videotoolboxenc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 270496b7a7..462d2a8fb6 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -100,6 +100,7 @@ static struct{ CFStringRef kVTCompressionPropertyKey_RealTime; CFStringRef kVTCompressionPropertyKey_TargetQualityForAlpha; + CFStringRef kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality; CFStringRef kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder; CFStringRef kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder; @@ -161,6 +162,8 @@ static void loadVTEncSymbols(){ GET_SYM(kVTCompressionPropertyKey_RealTime, "RealTime"); GET_SYM(kVTCompressionPropertyKey_TargetQualityForAlpha, "TargetQualityForAlpha"); + GET_SYM(kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality, + "PrioritizeEncodingSpeedOverQuality"); GET_SYM(kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, "EnableHardwareAcceleratedVideoEncoder"); @@ -237,6 +240,7 @@ typedef struct VTEncContext { int allow_sw; int require_sw; double alpha_quality; + int prio_speed; bool flushing; int has_b_frames; @@ -1146,6 +1150,16 @@ static int vtenc_create_encoder(AVCodecContext *avctx, return AVERROR_EXTERNAL; } + // prioritize speed over quality + if (vtctx->prio_speed) { + status = VTSessionSetProperty(vtctx->session, + compat_keys.kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality, + kCFBooleanTrue); + if (status) { + av_log(avctx, AV_LOG_WARNING, "PrioritizeEncodingSpeedOverQuality property is not supported on this device. Ignoring.\n"); + } + } + if ((vtctx->codec_id == AV_CODEC_ID_H264 || vtctx->codec_id == AV_CODEC_ID_HEVC) && max_rate > 0) { bytes_per_second_value = max_rate >> 3; @@ -2711,6 +2725,7 @@ static const AVOption h264_options[] = { { "ac", "CABAC entropy coding", 0, AV_OPT_TYPE_CONST, { .i64 = VT_CABAC }, INT_MIN, INT_MAX, VE, "coder" }, { "a53cc", "Use A53 Closed Captions (if available)", OFFSET(a53_cc), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, VE }, + { "prio_speed", "prioritize encoding speed", OFFSET(prio_speed), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, COMMON_OPTIONS { NULL }, @@ -2745,6 +2760,7 @@ static const AVOption hevc_options[] = { { "main10", "Main10 Profile", 0, AV_OPT_TYPE_CONST, { .i64 = HEVC_PROF_MAIN10 }, INT_MIN, INT_MAX, VE, "profile" }, { "alpha_quality", "Compression quality for the alpha channel", OFFSET(alpha_quality), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0.0, 1.0, VE }, + { "prio_speed", "prioritize encoding speed", OFFSET(prio_speed), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, COMMON_OPTIONS { NULL }, @@ -2785,6 +2801,8 @@ static const AVOption prores_options[] = { { "4444", "ProRes 4444", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_4444 }, INT_MIN, INT_MAX, VE, "profile" }, { "xq", "ProRes 4444 XQ", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_XQ }, INT_MIN, INT_MAX, VE, "profile" }, + { "prio_speed", "prioritize encoding speed", OFFSET(prio_speed), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE }, + COMMON_OPTIONS { NULL }, }; -- 2.32.0 (Apple Git-132) _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".