Created
June 23, 2017 19:27
-
-
Save tmm1/6f4bbe747cd29adb2ffb73012c324ed0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c | |
index e6d10928d5..c8131d299d 100644 | |
--- a/libavcodec/videotoolboxenc.c | |
+++ b/libavcodec/videotoolboxenc.c | |
@@ -896,8 +896,10 @@ static int vtenc_create_encoder(AVCodecContext *avctx, | |
VTCompressionSessionRef *session) | |
{ | |
VTEncContext *vtctx = avctx->priv_data; | |
+ double frame_rate = av_q2d(avctx->framerate); | |
SInt32 bit_rate = avctx->bit_rate; | |
SInt32 max_rate = avctx->rc_max_rate; | |
+ CFNumberRef frame_rate_num; | |
CFNumberRef bit_rate_num; | |
CFNumberRef bytes_per_second; | |
CFNumberRef one_second; | |
@@ -944,6 +946,21 @@ static int vtenc_create_encoder(AVCodecContext *avctx, | |
return AVERROR_EXTERNAL; | |
} | |
+ frame_rate_num = CFNumberCreate(kCFAllocatorDefault, | |
+ kCFNumberDoubleType, | |
+ &frame_rate); | |
+ if (!frame_rate_num) return AVERROR(ENOMEM); | |
+ | |
+ status = VTSessionSetProperty(vtctx->session, | |
+ kVTCompressionPropertyKey_ExpectedFrameRate, | |
+ frame_rate_num); | |
+ CFRelease(frame_rate_num); | |
+ | |
+ if (status) { | |
+ av_log(avctx, AV_LOG_ERROR, "Error setting framerate property: %d\n", status); | |
+ return AVERROR_EXTERNAL; | |
+ } | |
+ | |
bytes_per_second_value = max_rate >> 3; | |
bytes_per_second = CFNumberCreate(kCFAllocatorDefault, | |
kCFNumberSInt64Type, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment