diff --git a/Sources/FYVideoCompressor/FYVideoCompressor.swift b/Sources/FYVideoCompressor/FYVideoCompressor.swift index 2849367..bfe85b7 100644 --- a/Sources/FYVideoCompressor/FYVideoCompressor.swift +++ b/Sources/FYVideoCompressor/FYVideoCompressor.swift @@ -183,7 +183,8 @@ public class FYVideoCompressor { let videoSettings = createVideoSettingsWithBitrate(targetVideoBitrate, maxKeyFrameInterval: 10, - size: scaleSize) + size: scaleSize, + targetFPS: quality.value.fps) #if DEBUG print("************** Video info **************") #endif @@ -256,7 +257,8 @@ public class FYVideoCompressor { let targetSize = calculateSizeWithScale(config.scale, originalSize: videoTrack.naturalSize) let videoSettings = createVideoSettingsWithBitrate(targetVideoBitrate, maxKeyFrameInterval: config.videomaxKeyFrameInterval, - size: targetSize) + size: targetSize, + targetFPS: config.fps) var audioTrack: AVAssetTrack? var audioSettings: [String: Any]? @@ -457,11 +459,12 @@ public class FYVideoCompressor { } - private func createVideoSettingsWithBitrate(_ bitrate: Float, maxKeyFrameInterval: Int, size: CGSize) -> [String: Any] { + private func createVideoSettingsWithBitrate(_ bitrate: Float, maxKeyFrameInterval: Int, size: CGSize, targetFPS: Float = 30) -> [String: Any] { return [AVVideoCodecKey: AVVideoCodecType.h264, AVVideoWidthKey: size.width, AVVideoHeightKey: size.height, AVVideoScalingModeKey: AVVideoScalingModeResizeAspectFill, + AVVideoExpectedSourceFrameRateKey: targetFPS, AVVideoCompressionPropertiesKey: [AVVideoAverageBitRateKey: bitrate, AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel, AVVideoH264EntropyModeKey: AVVideoH264EntropyModeCABAC, diff --git a/Sources/FYVideoCompressor/VideoFrameReducer.swift b/Sources/FYVideoCompressor/VideoFrameReducer.swift index b9c8a49..59f6a44 100644 --- a/Sources/FYVideoCompressor/VideoFrameReducer.swift +++ b/Sources/FYVideoCompressor/VideoFrameReducer.swift @@ -29,14 +29,16 @@ public struct ReduceFrameEvenlySpaced: VideoFrameReducer { let originalFrames = (0..