Posts

Post not yet marked as solved
0 Replies
513 Views
This question is similar with VTCompressionSessionEncodeFrame performance decrease I also post this question on StackOverflow In my demo, the average execution time of VTCompressionSessionEncodeFrame in iphone12 is 10ms while iphoneXs only costs 6ms. If I decrease the frequency of calling that function, the execution time also decreases but the total time(delay+execution time) stays same about 11ms on iphone12 and 7ms on iphoneXs. I try various configuration of VTCompressionSession, but the result (iphone12 > iphoneXs) never change! Here is the configuration of VTCompressionSession bool VideoToolboxEncoder::InitCompressionSession() {  CFMutableDictionaryRef sourceImageBufferAttributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, NULL);  CFDictionarySetValue(sourceImageBufferAttributes, kCVPixelBufferOpenGLESCompatibilityKey, kCFBooleanTrue);  OSType target_pixelformat = kCVPixelFormatType_420YpCbCr8Planar;  dict_set_i32(sourceImageBufferAttributes,          kCVPixelBufferPixelFormatTypeKey, target_pixelformat);  dict_set_i32(sourceImageBufferAttributes,          kCVPixelBufferBytesPerRowAlignmentKey, 16);  CFDictionarySetValue(sourceImageBufferAttributes, kCVPixelBufferWidthKey, CFNumberCreate(NULL, kCFNumberIntType, &codec_settings.width));  CFDictionarySetValue(sourceImageBufferAttributes, kCVPixelBufferHeightKey, CFNumberCreate(NULL, kCFNumberIntType, &codec_settings.height));  OSStatus status = VTCompressionSessionCreate(NULL,                    codec_settings.width,                    codec_settings.height,                    kCMVideoCodecType_HEVC,                    NULL,                    sourceImageBufferAttributes,                    NULL,                    encodeComplete,                    this,                    &compression_session_);     status = VTSessionSetProperty(compression_session_, kVTCompressionPropertyKey_RealTime, kCFBooleanTrue);  status = VTSessionSetProperty(compression_session_, kVTCompressionPropertyKey_AllowFrameReordering, kCFBooleanFalse);  status = VTSessionSetProperty(compression_session_, kVTCompressionPropertyKey_ExpectedFrameRate, (__bridge CFTypeRef)@(29.97));  status = VTSessionSetProperty(compression_session_, kVTCompressionPropertyKey_MaxKeyFrameInterval,                 (__bridge CFTypeRef)@(codec_settings.gop_size));  CFStringRef profileRef;  profileRef = kVTProfileLevel_HEVC_Main_AutoLevel;  status = VTSessionSetProperty(compression_session_, kVTCompressionPropertyKey_ProfileLevel, profileRef);  status = VTSessionSetProperty(compression_session_, kVTCompressionPropertyKey_AllowOpenGOP, kCFBooleanFalse);  status = VTSessionSetProperty(compression_session_, kVTCompressionPropertyKey_AverageBitRate, (__bridge CFTypeRef)@(codec_settings.bitrate));  status = VTSessionSetProperty(compression_session_, kVTCompressionPropertyKey_DataRateLimits, (__bridge CFTypeRef)@[@20000000, @2]);  VTCompressionSessionPrepareToEncodeFrames(compression_session_);  return 0; } I also try to export video with AVAssetWriter and I get the same result. It's unexpected that videotoolbox performance decreases on newer iphones. I want to figure out this problem is due to my incorrect configuration or hardware of iphone. Has anyone encountered the same problem?If someone could help with this issue would be really grateful!
Posted
by xxyang.
Last updated
.