Skip to content

Instantly share code, notes, and snippets.

@tmm1
Created June 23, 2017 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmm1/6f4bbe747cd29adb2ffb73012c324ed0 to your computer and use it in GitHub Desktop.
Save tmm1/6f4bbe747cd29adb2ffb73012c324ed0 to your computer and use it in GitHub Desktop.
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