* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
[not found] <80886934-2099-4FE0-A95D-F9B6658F777F@lisanet.de>
@ 2022-04-14 6:48 ` Simone Karin Lehmann
2022-04-14 8:13 ` Thilo Borgmann
0 siblings, 1 reply; 17+ messages in thread
From: Simone Karin Lehmann @ 2022-04-14 6:48 UTC (permalink / raw)
To: ffmpeg-devel
Somehow it seems, that this patch never got onto the mailing list. So may I kindly ask you to review it.
--
Stay hungry, stay foolish
> Am 26.01.2022 um 17:31 schrieb Simone Karin Lehmann <simone@lisanet.de>:
>
>
> The patch adds an option to the hevc_videotoolbox encoder to prioritize speed for Macs with Apple Silicon CPU.
>
> This speeds up encodings up to 50% - 70%. In conjunction with the qcale option -q, visible quality will be unchanged. The increase in file size is very moderate, although still depending on the source material.
>
>
> Signed-off-by: Simone Karin Lehmann <simone@lisanet.de>
> ---
> libavcodec/videotoolboxenc.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 418ff00b8d..ab0dad6cbc 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -236,6 +236,7 @@ typedef struct VTEncContext {
> int allow_sw;
> int require_sw;
> double alpha_quality;
> + int64_t prio_speed;
>
> bool flushing;
> int has_b_frames;
> @@ -1145,6 +1146,17 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
> return AVERROR_EXTERNAL;
> }
>
> + // prioritize speed over quality
> + if (vtctx->prio_speed) {
> + status = VTSessionSetProperty(vtctx->session,
> + kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality,
> + kCFBooleanTrue);
> + if (status) {
> + av_log(avctx, AV_LOG_ERROR, "Error setting PrioritizeEncodingSpeedOverQuality property: %d\n", status);
> + return AVERROR_EXTERNAL;
> + }
> + }
> +
> 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;
> @@ -2744,6 +2756,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 },
> --
> 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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-14 6:48 ` [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed Simone Karin Lehmann
@ 2022-04-14 8:13 ` Thilo Borgmann
2022-04-21 15:42 ` Simone Karin Lehmann
0 siblings, 1 reply; 17+ messages in thread
From: Thilo Borgmann @ 2022-04-14 8:13 UTC (permalink / raw)
To: ffmpeg-devel
Hi,
Am 14.04.22 um 08:48 schrieb Simone Karin Lehmann:
> Somehow it seems, that this patch never got onto the mailing list. So may I kindly ask you to review it.
>
> --
> Stay hungry, stay foolish
>
>> Am 26.01.2022 um 17:31 schrieb Simone Karin Lehmann <simone@lisanet.de>:
>>
>>
>> The patch adds an option to the hevc_videotoolbox encoder to prioritize speed for Macs with Apple Silicon CPU.
>>
>> This speeds up encodings up to 50% - 70%. In conjunction with the qcale option -q, visible quality will be unchanged. The increase in file size is very moderate, although still depending on the source material.
>>
>>
>> Signed-off-by: Simone Karin Lehmann <simone@lisanet.de>
>> ---
>> libavcodec/videotoolboxenc.c | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
>> index 418ff00b8d..ab0dad6cbc 100644
>> --- a/libavcodec/videotoolboxenc.c
>> +++ b/libavcodec/videotoolboxenc.c
>> @@ -236,6 +236,7 @@ typedef struct VTEncContext {
>> int allow_sw;
>> int require_sw;
>> double alpha_quality;
>> + int64_t prio_speed;
int64_t is definitely overkill.
>>
>> bool flushing;
>> int has_b_frames;
>> @@ -1145,6 +1146,17 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
>> return AVERROR_EXTERNAL;
>> }
>>
>> + // prioritize speed over quality
>> + if (vtctx->prio_speed) {
>> + status = VTSessionSetProperty(vtctx->session,
>> + kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality,
>> + kCFBooleanTrue);
>> + if (status) {
>> + av_log(avctx, AV_LOG_ERROR, "Error setting PrioritizeEncodingSpeedOverQuality property: %d\n", status);
>> + return AVERROR_EXTERNAL;
>> + }
If its called to priotize speed over qual, why not just print a warning and continue without this option?
>> + }
>> +
>> 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;
>> @@ -2744,6 +2756,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 },
Just use an int.
Thanks,
Thilo
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-14 8:13 ` Thilo Borgmann
@ 2022-04-21 15:42 ` Simone Karin Lehmann
2022-04-22 16:24 ` Andreas Rheinhardt
0 siblings, 1 reply; 17+ messages in thread
From: Simone Karin Lehmann @ 2022-04-21 15:42 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> Am 14.04.2022 um 10:13 schrieb Thilo Borgmann <thilo.borgmann@mail.de>:
>
> Hi,
>
>>> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
>>> index 418ff00b8d..ab0dad6cbc 100644
>>> --- a/libavcodec/videotoolboxenc.c
>>> +++ b/libavcodec/videotoolboxenc.c
>>> @@ -236,6 +236,7 @@ typedef struct VTEncContext {
>>> int allow_sw;
>>> int require_sw;
>>> double alpha_quality;
>>> + int64_t prio_speed;
>
> int64_t is definitely overkill.
I just wanted to make it consistent with hevc_options[] and other variables of AV_OPT_TYPE_BOOL. these are noted as .i64.
Anyway, I changed it to int.
>
>>>
>>> bool flushing;
>>> int has_b_frames;
>>> @@ -1145,6 +1146,17 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
>>> return AVERROR_EXTERNAL;
>>> }
>>>
>>> + // prioritize speed over quality
>>> + if (vtctx->prio_speed) {
>>> + status = VTSessionSetProperty(vtctx->session,
>>> + kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality,
>>> + kCFBooleanTrue);
>>> + if (status) {
>>> + av_log(avctx, AV_LOG_ERROR, "Error setting PrioritizeEncodingSpeedOverQuality property: %d\n", status);
>>> + return AVERROR_EXTERNAL;
>>> + }
>
> If its called to priotize speed over qual, why not just print a warning and continue without this option?
You’re right. A warning seems much better. Changed this too.
Here’s the modified patch.
Signed-off-by: Simone Karin Lehmann <simone@lisanet.de>
---
libavcodec/videotoolboxenc.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 270496b7a7..cf931569d1 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -237,6 +237,7 @@ typedef struct VTEncContext {
int allow_sw;
int require_sw;
double alpha_quality;
+ int prio_speed;
bool flushing;
int has_b_frames;
@@ -1146,6 +1147,16 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
return AVERROR_EXTERNAL;
}
+ // prioritize speed over quality
+ if (vtctx->prio_speed) {
+ status = VTSessionSetProperty(vtctx->session,
+ 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;
@@ -2745,6 +2756,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 },
--
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-21 15:42 ` Simone Karin Lehmann
@ 2022-04-22 16:24 ` Andreas Rheinhardt
2022-04-22 16:52 ` Thilo Borgmann
0 siblings, 1 reply; 17+ messages in thread
From: Andreas Rheinhardt @ 2022-04-22 16:24 UTC (permalink / raw)
To: ffmpeg-devel
Simone Karin Lehmann:
>
>
>> Am 14.04.2022 um 10:13 schrieb Thilo Borgmann <thilo.borgmann@mail.de>:
>>
>> Hi,
>>
>>>> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
>>>> index 418ff00b8d..ab0dad6cbc 100644
>>>> --- a/libavcodec/videotoolboxenc.c
>>>> +++ b/libavcodec/videotoolboxenc.c
>>>> @@ -236,6 +236,7 @@ typedef struct VTEncContext {
>>>> int allow_sw;
>>>> int require_sw;
>>>> double alpha_quality;
>>>> + int64_t prio_speed;
>>
>> int64_t is definitely overkill.
>
> I just wanted to make it consistent with hevc_options[] and other variables of AV_OPT_TYPE_BOOL. these are noted as .i64.
AV_OPT_TYPE_BOOL expects an int target; the i64 is just the member used
for initialization (it is used because an int64_t can hold all the
values that make sense for a boolean -- it is therefore used for all
AV_OPT_TYPE_INT as well).
This also means that int64_t is not only overkill, but wrong (but it
happens to work on little-endian architectures).
> Anyway, I changed it to int.
>
>>
>>>>
>>>> bool flushing;
>>>> int has_b_frames;
>>>> @@ -1145,6 +1146,17 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
>>>> return AVERROR_EXTERNAL;
>>>> }
>>>>
>>>> + // prioritize speed over quality
>>>> + if (vtctx->prio_speed) {
>>>> + status = VTSessionSetProperty(vtctx->session,
>>>> + kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality,
>>>> + kCFBooleanTrue);
>>>> + if (status) {
>>>> + av_log(avctx, AV_LOG_ERROR, "Error setting PrioritizeEncodingSpeedOverQuality property: %d\n", status);
>>>> + return AVERROR_EXTERNAL;
>>>> + }
>>
>> If its called to priotize speed over qual, why not just print a warning and continue without this option?
>
> You’re right. A warning seems much better. Changed this too.
>
> Here’s the modified patch.
>
> Signed-off-by: Simone Karin Lehmann <simone@lisanet.de>
> ---
> libavcodec/videotoolboxenc.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 270496b7a7..cf931569d1 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -237,6 +237,7 @@ typedef struct VTEncContext {
> int allow_sw;
> int require_sw;
> double alpha_quality;
> + int prio_speed;
>
> bool flushing;
> int has_b_frames;
> @@ -1146,6 +1147,16 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
> return AVERROR_EXTERNAL;
> }
>
> + // prioritize speed over quality
> + if (vtctx->prio_speed) {
> + status = VTSessionSetProperty(vtctx->session,
> + 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;
> @@ -2745,6 +2756,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 },
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-22 16:24 ` Andreas Rheinhardt
@ 2022-04-22 16:52 ` Thilo Borgmann
2022-04-23 12:31 ` Simone Karin Lehmann
0 siblings, 1 reply; 17+ messages in thread
From: Thilo Borgmann @ 2022-04-22 16:52 UTC (permalink / raw)
To: ffmpeg-devel
Am 22.04.22 um 18:24 schrieb Andreas Rheinhardt:
> Simone Karin Lehmann:
>>
>>
>>> Am 14.04.2022 um 10:13 schrieb Thilo Borgmann <thilo.borgmann@mail.de>:
>>>
>>> Hi,
>>>
>>>>> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
>>>>> index 418ff00b8d..ab0dad6cbc 100644
>>>>> --- a/libavcodec/videotoolboxenc.c
>>>>> +++ b/libavcodec/videotoolboxenc.c
>>>>> @@ -236,6 +236,7 @@ typedef struct VTEncContext {
>>>>> int allow_sw;
>>>>> int require_sw;
>>>>> double alpha_quality;
>>>>> + int64_t prio_speed;
>>>
>>> int64_t is definitely overkill.
>>
>> I just wanted to make it consistent with hevc_options[] and other variables of AV_OPT_TYPE_BOOL. these are noted as .i64.
>
> AV_OPT_TYPE_BOOL expects an int target; the i64 is just the member used
> for initialization (it is used because an int64_t can hold all the
> values that make sense for a boolean -- it is therefore used for all
> AV_OPT_TYPE_INT as well).
> This also means that int64_t is not only overkill, but wrong (but it
> happens to work on little-endian architectures).
Thanks!
>> Anyway, I changed it to int.
>>
>>>
>>>>>
>>>>> bool flushing;
>>>>> int has_b_frames;
>>>>> @@ -1145,6 +1146,17 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
>>>>> return AVERROR_EXTERNAL;
>>>>> }
>>>>>
>>>>> + // prioritize speed over quality
>>>>> + if (vtctx->prio_speed) {
>>>>> + status = VTSessionSetProperty(vtctx->session,
>>>>> + kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality,
>>>>> + kCFBooleanTrue);
>>>>> + if (status) {
>>>>> + av_log(avctx, AV_LOG_ERROR, "Error setting PrioritizeEncodingSpeedOverQuality property: %d\n", status);
>>>>> + return AVERROR_EXTERNAL;
>>>>> + }
>>>
>>> If its called to priotize speed over qual, why not just print a warning and continue without this option?
>>
>> You’re right. A warning seems much better. Changed this too.
>>
>> Here’s the modified patch.
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.
-Thilo
>> Signed-off-by: Simone Karin Lehmann <simone@lisanet.de>
>> ---
>> libavcodec/videotoolboxenc.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
>> index 270496b7a7..cf931569d1 100644
>> --- a/libavcodec/videotoolboxenc.c
>> +++ b/libavcodec/videotoolboxenc.c
>> @@ -237,6 +237,7 @@ typedef struct VTEncContext {
>> int allow_sw;
>> int require_sw;
>> double alpha_quality;
>> + int prio_speed;
>>
>> bool flushing;
>> int has_b_frames;
>> @@ -1146,6 +1147,16 @@ static int vtenc_create_encoder(AVCodecContext *avctx,
>> return AVERROR_EXTERNAL;
>> }
>>
>> + // prioritize speed over quality
>> + if (vtctx->prio_speed) {
>> + status = VTSessionSetProperty(vtctx->session,
>> + 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;
>> @@ -2745,6 +2756,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 },
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-22 16:52 ` Thilo Borgmann
@ 2022-04-23 12:31 ` Simone Karin Lehmann
2022-04-23 15:07 ` Thilo Borgmann
2022-04-25 19:14 ` Rick Kern
0 siblings, 2 replies; 17+ messages in thread
From: Simone Karin Lehmann @ 2022-04-23 12:31 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> Am 22.04.2022 um 18:52 schrieb Thilo Borgmann <thilo.borgmann@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 <simone@lisanet.de <mailto:simone@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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-23 12:31 ` Simone Karin Lehmann
@ 2022-04-23 15:07 ` Thilo Borgmann
2022-04-23 15:42 ` Simone Karin Lehmann
2022-04-25 19:14 ` Rick Kern
1 sibling, 1 reply; 17+ messages in thread
From: Thilo Borgmann @ 2022-04-23 15:07 UTC (permalink / raw)
To: ffmpeg-devel
Am 23.04.22 um 14:31 schrieb Simone Karin Lehmann:
>
>
>> Am 22.04.2022 um 18:52 schrieb Thilo Borgmann <thilo.borgmann@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 <simone@lisanet.de <mailto:simone@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");
If that works I'd be happy. Does not apply for me anymore (on HEAD), though?
-Thilo
> @@ -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 },
> };
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-23 15:07 ` Thilo Borgmann
@ 2022-04-23 15:42 ` Simone Karin Lehmann
2022-04-23 19:56 ` Thilo Borgmann
0 siblings, 1 reply; 17+ messages in thread
From: Simone Karin Lehmann @ 2022-04-23 15:42 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> Am 23.04.2022 um 17:07 schrieb Thilo Borgmann <thilo.borgmann@mail.de>:
>
>
> If that works I'd be happy. Does not apply for me anymore (on HEAD), though?
>
>
hhmm, the patch applies for me on current HEAD. I’ve tested it a few moments ago on a fresh downloaded git snapshot.
Maybe a former patch from me still there in your source tree?
Simone
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-23 15:42 ` Simone Karin Lehmann
@ 2022-04-23 19:56 ` Thilo Borgmann
2022-04-23 20:51 ` Simone Karin Lehmann
0 siblings, 1 reply; 17+ messages in thread
From: Thilo Borgmann @ 2022-04-23 19:56 UTC (permalink / raw)
To: ffmpeg-devel
Am 23.04.22 um 17:42 schrieb Simone Karin Lehmann:
>
>
>> Am 23.04.2022 um 17:07 schrieb Thilo Borgmann <thilo.borgmann@mail.de>:
>>
>>
>> If that works I'd be happy. Does not apply for me anymore (on HEAD), though?
>>
>>
>
> hhmm, the patch applies for me on current HEAD. I’ve tested it a few moments ago on a fresh downloaded git snapshot.
>
> Maybe a former patch from me still there in your source tree?
Also cloned into a new one, but corrupt @75:
Thilos-Mac-mini:github borgmann$ git clone git://source.ffmpeg.org/ffmpeg.git FFmpegNew
Cloning into 'FFmpegNew'...
remote: Enumerating objects: 662389, done.
remote: Counting objects: 100% (662389/662389), done.
remote: Compressing objects: 100% (132367/132367), done.
remote: Total 662389 (delta 536006), reused 653667 (delta 528727)
Receiving objects: 100% (662389/662389), 130.66 MiB | 6.20 MiB/s, done.
Resolving deltas: 100% (536006/536006), done.
Checking out files: 100% (7728/7728), done.
Thilos-Mac-mini:github borgmann$ cd FFmpegNew/
Thilos-Mac-mini:FFmpegNew borgmann$ git am ../patches/vte/
0001-selfmade.patch
Re_ [FFmpeg-devel] [PATCH] libavcodec_videotoolboxenc.c_ add option to hevc encoder to prioritize speed. - Simone Karin Lehmann <simone@lisanet.de> - 2022-04-21 1742.eml
Re_ [FFmpeg-devel] [PATCH] libavcodec_videotoolboxenc.c_ add option to hevc encoder to prioritize speed. - Simone Karin Lehmann <simone@lisanet.de> - 2022-04-23 1431.eml
Re_ [FFmpeg-devel] [PATCH] libavcodec_videotoolboxenc.c_ add option to hevc encoder to prioritize speed. - Simone Karin Lehmann <simone@lisanet.de> - 2022-04-23 1431.patch
Thilos-Mac-mini:FFmpegNew borgmann$ git am ../patches/vte/Re_\ \[FFmpeg-devel\]\ \[PATCH\]\ libavcodec_videotoolboxenc.c_\ add\ option\ to\ hevc\ encoder\ to\ prioritize\ speed.\ -\ Simone\ Karin\ Lehmann\ \<simone\@lisanet.de\>\ -\ 2022-04-23\ 1431.eml
Applying: libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
error: corrupt patch at line 75
Patch failed at 0001 libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
hint: Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Thilos-Mac-mini:FFmpegNew borgmann$ git log -1
commit ce23794b91031162da365a0d389fd0330cdb9486 (HEAD -> master, origin/master, origin/HEAD)
Author: Paul B Mahol <onemda@gmail.com>
Date: Sat Apr 23 19:09:30 2022 +0200
avfilter/avf_showspectrum: filter support all channel counts
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-23 19:56 ` Thilo Borgmann
@ 2022-04-23 20:51 ` Simone Karin Lehmann
2022-04-24 10:10 ` Thilo Borgmann
0 siblings, 1 reply; 17+ messages in thread
From: Simone Karin Lehmann @ 2022-04-23 20:51 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 841 bytes --]
> Am 23.04.2022 um 21:56 schrieb Thilo Borgmann <thilo.borgmann@mail.de>:
>
> Am 23.04.22 um 17:42 schrieb Simone Karin Lehmann:
>>> Am 23.04.2022 um 17:07 schrieb Thilo Borgmann <thilo.borgmann@mail.de>:
>>>
>>>
>>> If that works I'd be happy. Does not apply for me anymore (on HEAD), though?
>>>
>>>
>> hhmm, the patch applies for me on current HEAD. I’ve tested it a few moments ago on a fresh downloaded git snapshot.
>> Maybe a former patch from me still there in your source tree?
>
> Also cloned into a new one, but corrupt @75:
>
Weird. Apple Mail seems to somehow change the encoding of the mail and I couldn’t get the *.eml to apply correctly too. Never encountered that before.
I've attached the patch as a file. Hope that’s ok on this mailing list.
Sorry for the inconvenience.
Simone
[-- Attachment #2: 0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch --]
[-- Type: application/octet-stream, Size: 4034 bytes --]
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-23 20:51 ` Simone Karin Lehmann
@ 2022-04-24 10:10 ` Thilo Borgmann
0 siblings, 0 replies; 17+ messages in thread
From: Thilo Borgmann @ 2022-04-24 10:10 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Aman Gupta, Rick Kern
Am 23.04.22 um 22:51 schrieb Simone Karin Lehmann:
>
>
>> Am 23.04.2022 um 21:56 schrieb Thilo Borgmann <thilo.borgmann@mail.de>:
>>
>> Am 23.04.22 um 17:42 schrieb Simone Karin Lehmann:
>>>> Am 23.04.2022 um 17:07 schrieb Thilo Borgmann <thilo.borgmann@mail.de>:
>>>>
>>>>
>>>> If that works I'd be happy. Does not apply for me anymore (on HEAD), though?
>>>>
>>>>
>>> hhmm, the patch applies for me on current HEAD. I’ve tested it a few moments ago on a fresh downloaded git snapshot.
>>> Maybe a former patch from me still there in your source tree?
>>
>> Also cloned into a new one, but corrupt @75:
>>
>
> Weird. Apple Mail seems to somehow change the encoding of the mail and I couldn’t get the *.eml to apply correctly too. Never encountered that before.
>
> I've attached the patch as a file. Hope that’s ok on this mailing list.
> Sorry for the inconvenience.
It is and patch LGTM. I CC'd the maintainers as they didn't comment yet.
Thanks,
Thilo
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-23 12:31 ` Simone Karin Lehmann
2022-04-23 15:07 ` Thilo Borgmann
@ 2022-04-25 19:14 ` Rick Kern
2022-04-25 20:33 ` Simone Karin Lehmann
1 sibling, 1 reply; 17+ messages in thread
From: Rick Kern @ 2022-04-25 19:14 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sat, Apr 23, 2022 at 8:31 AM Simone Karin Lehmann <simone@lisanet.de>
wrote:
>
>
> > Am 22.04.2022 um 18:52 schrieb Thilo Borgmann <thilo.borgmann@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 <simone@lisanet.de <mailto:
> simone@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 },
>
It might be simpler to make the default value of prio_speed -1, and set
this property on the encoder session only when it's non-negative. Then we
won't need to worry about the default value changing for different codecs
or different OS versions. It could also be moved into COMMON_OPTIONS in
this case.
>
> 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-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-25 19:14 ` Rick Kern
@ 2022-04-25 20:33 ` Simone Karin Lehmann
2022-05-01 17:31 ` Simone Karin Lehmann
0 siblings, 1 reply; 17+ messages in thread
From: Simone Karin Lehmann @ 2022-04-25 20:33 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 785 bytes --]
> Am 25.04.2022 um 21:14 schrieb Rick Kern <kernrj@gmail.com>:
>
>>
>> { "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 },
>>
> It might be simpler to make the default value of prio_speed -1, and set
> this property on the encoder session only when it's non-negative. Then we
> won't need to worry about the default value changing for different codecs
> or different OS versions. It could also be moved into COMMON_OPTIONS in
> this case.
oh yes, that’s way better. I didn’t think of that in the first place. Thanks for the hint.
Here’s the modified patch
Simone
[-- Attachment #2: 0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch --]
[-- Type: application/octet-stream, Size: 3289 bytes --]
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-04-25 20:33 ` Simone Karin Lehmann
@ 2022-05-01 17:31 ` Simone Karin Lehmann
2022-05-01 18:25 ` Richard Kern
0 siblings, 1 reply; 17+ messages in thread
From: Simone Karin Lehmann @ 2022-05-01 17:31 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1.1: Type: text/plain, Size: 1025 bytes --]
Hi,
may I kindly ask you to check, if this patch could now be applied?
Regards
Simone
Von meinem iPad gesendet
> Am 25.04.2022 um 22:33 schrieb Simone Karin Lehmann <simone@lisanet.de>:
>
>
>
>>> Am 25.04.2022 um 21:14 schrieb Rick Kern <kernrj@gmail.com>:
>>>
>>>
>>> { "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 },
>>>
>> It might be simpler to make the default value of prio_speed -1, and set
>> this property on the encoder session only when it's non-negative. Then we
>> won't need to worry about the default value changing for different codecs
>> or different OS versions. It could also be moved into COMMON_OPTIONS in
>> this case.
>
> oh yes, that’s way better. I didn’t think of that in the first place. Thanks for the hint.
>
> Here’s the modified patch
>
> Simone
>
[-- Attachment #1.1.2: 0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch --]
[-- Type: application/octet-stream, Size: 3289 bytes --]
[-- Attachment #1.1.3: Type: text/plain, Size: 265 bytes --]
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
[-- Attachment #1.2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2471 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-05-01 17:31 ` Simone Karin Lehmann
@ 2022-05-01 18:25 ` Richard Kern
2022-05-01 19:11 ` Simone Karin Lehmann
0 siblings, 1 reply; 17+ messages in thread
From: Richard Kern @ 2022-05-01 18:25 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 1193 bytes --]
> On May 1, 2022, at 1:31 PM, Simone Karin Lehmann <simone@lisanet.de> wrote:
>
> Hi,
>
> may I kindly ask you to check, if this patch could now be applied?
I’ll look at it today.
>
> Regards
> Simone
>
> Von meinem iPad gesendet
>
>> Am 25.04.2022 um 22:33 schrieb Simone Karin Lehmann <simone@lisanet.de>:
>>
>>
>>
>>>>> Am 25.04.2022 um 21:14 schrieb Rick Kern <kernrj@gmail.com>:
>>>>>
>>>>>
>>>>> { "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 },
>>>>>
>>> It might be simpler to make the default value of prio_speed -1, and set
>>> this property on the encoder session only when it's non-negative. Then we
>>> won't need to worry about the default value changing for different codecs
>>> or different OS versions. It could also be moved into COMMON_OPTIONS in
>>> this case.
>>
>> oh yes, that’s way better. I didn’t think of that in the first place. Thanks for the hint.
>>
>> Here’s the modified patch
>>
>> Simone
>>
[-- Attachment #2: 0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch --]
[-- Type: application/octet-stream, Size: 3289 bytes --]
[-- Attachment #3: Type: text/plain, Size: 541 bytes --]
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
[-- Attachment #4: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-05-01 18:25 ` Richard Kern
@ 2022-05-01 19:11 ` Simone Karin Lehmann
2022-05-02 15:18 ` Rick Kern
0 siblings, 1 reply; 17+ messages in thread
From: Simone Karin Lehmann @ 2022-05-01 19:11 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 151 bytes --]
Hi,
… I’m so sorry, the patch I recently sent didn’t test the prio_speed bool. This corrects it.
I really sorry. :-/
Regards
Simone
[-- Attachment #2: 0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch --]
[-- Type: application/octet-stream, Size: 3326 bytes --]
[-- Attachment #3: Type: text/plain, Size: 2229 bytes --]
> Am 01.05.2022 um 20:25 schrieb Richard Kern <kernrj@gmail.com>:
>
>
>
>> On May 1, 2022, at 1:31 PM, Simone Karin Lehmann <simone@lisanet.de> wrote:
>>
>> Hi,
>>
>> may I kindly ask you to check, if this patch could now be applied?
> I’ll look at it today.
>
>>
>> Regards
>> Simone
>>
>> Von meinem iPad gesendet
>>
>>> Am 25.04.2022 um 22:33 schrieb Simone Karin Lehmann <simone@lisanet.de>:
>>>
>>>
>>>
>>>>>> Am 25.04.2022 um 21:14 schrieb Rick Kern <kernrj@gmail.com>:
>>>>>>
>>>>>>
>>>>>> { "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 },
>>>>>>
>>>> It might be simpler to make the default value of prio_speed -1, and set
>>>> this property on the encoder session only when it's non-negative. Then we
>>>> won't need to worry about the default value changing for different codecs
>>>> or different OS versions. It could also be moved into COMMON_OPTIONS in
>>>> this case.
>>>
>>> oh yes, that’s way better. I didn’t think of that in the first place. Thanks for the hint.
>>>
>>> Here’s the modified patch
>>>
>>> Simone
>>>
> <0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch>
>>
>>>
>>> _______________________________________________
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>> To unsubscribe, visit link above, or email
>>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
[-- Attachment #4: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.
2022-05-01 19:11 ` Simone Karin Lehmann
@ 2022-05-02 15:18 ` Rick Kern
0 siblings, 0 replies; 17+ messages in thread
From: Rick Kern @ 2022-05-02 15:18 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sun, May 1, 2022 at 12:12 PM Simone Karin Lehmann <simone@lisanet.de>
wrote:
> Hi,
>
> … I’m so sorry, the patch I recently sent didn’t test the prio_speed bool.
> This corrects it.
>
> I really sorry. :-/
>
> Regards
> Simone
>
Pushed, with some commit message changes. The first line of the commit
message should start with a short topic - in this case
lavc/videotoolboxenc, followed by a brief description. Commit messages
should also be limited to an 80-character width when practical.
>
>
> > Am 01.05.2022 um 20:25 schrieb Richard Kern <kernrj@gmail.com>:
> >
> >
> >
> >> On May 1, 2022, at 1:31 PM, Simone Karin Lehmann <simone@lisanet.de>
> wrote:
> >>
> >> Hi,
> >>
> >> may I kindly ask you to check, if this patch could now be applied?
> > I’ll look at it today.
> >
> >>
> >> Regards
> >> Simone
> >>
> >> Von meinem iPad gesendet
> >>
> >>> Am 25.04.2022 um 22:33 schrieb Simone Karin Lehmann <simone@lisanet.de
> >:
> >>>
> >>>
> >>>
> >>>>>> Am 25.04.2022 um 21:14 schrieb Rick Kern <kernrj@gmail.com>:
> >>>>>>
> >>>>>>
> >>>>>> { "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 },
> >>>>>>
> >>>> It might be simpler to make the default value of prio_speed -1, and
> set
> >>>> this property on the encoder session only when it's non-negative.
> Then we
> >>>> won't need to worry about the default value changing for different
> codecs
> >>>> or different OS versions. It could also be moved into COMMON_OPTIONS
> in
> >>>> this case.
> >>>
> >>> oh yes, that’s way better. I didn’t think of that in the first place.
> Thanks for the hint.
> >>>
> >>> Here’s the modified patch
> >>>
> >>> Simone
> >>>
> > <0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch>
> >>
> >>>
> >>> _______________________________________________
> >>> ffmpeg-devel mailing list
> >>> ffmpeg-devel@ffmpeg.org
> >>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>>
> >>> To unsubscribe, visit link above, or email
> >>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> >> _______________________________________________
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel@ffmpeg.org
> >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >> To unsubscribe, visit link above, or email
> >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2022-05-02 15:19 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <80886934-2099-4FE0-A95D-F9B6658F777F@lisanet.de>
2022-04-14 6:48 ` [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed Simone Karin Lehmann
2022-04-14 8:13 ` Thilo Borgmann
2022-04-21 15:42 ` Simone Karin Lehmann
2022-04-22 16:24 ` Andreas Rheinhardt
2022-04-22 16:52 ` Thilo Borgmann
2022-04-23 12:31 ` Simone Karin Lehmann
2022-04-23 15:07 ` Thilo Borgmann
2022-04-23 15:42 ` Simone Karin Lehmann
2022-04-23 19:56 ` Thilo Borgmann
2022-04-23 20:51 ` Simone Karin Lehmann
2022-04-24 10:10 ` Thilo Borgmann
2022-04-25 19:14 ` Rick Kern
2022-04-25 20:33 ` Simone Karin Lehmann
2022-05-01 17:31 ` Simone Karin Lehmann
2022-05-01 18:25 ` Richard Kern
2022-05-01 19:11 ` Simone Karin Lehmann
2022-05-02 15:18 ` Rick Kern
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git