From 9cbfcd06308cc2d270f1a2e170cf37074975a916 Mon Sep 17 00:00:00 2001 From: kintan Date: Thu, 10 Oct 2024 21:40:22 +0800 Subject: [PATCH] update --- Sources/KSPlayer/AVPlayer/KSAVPlayer.swift | 4 ++-- Sources/KSPlayer/Core/Utility.swift | 10 +++++----- Sources/KSPlayer/MEPlayer/AVFoundationExtension.swift | 2 +- Sources/KSPlayer/MEPlayer/Resample.swift | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Sources/KSPlayer/AVPlayer/KSAVPlayer.swift b/Sources/KSPlayer/AVPlayer/KSAVPlayer.swift index 954757e3a..99a1aa4df 100644 --- a/Sources/KSPlayer/AVPlayer/KSAVPlayer.swift +++ b/Sources/KSPlayer/AVPlayer/KSAVPlayer.swift @@ -570,7 +570,7 @@ class AVMediaPlayerTrack: MediaPlayerTrack { } public extension AVAsset { - func ceateImageGenerator() -> AVAssetImageGenerator { + func createImageGenerator() -> AVAssetImageGenerator { let imageGenerator = AVAssetImageGenerator(asset: self) imageGenerator.requestedTimeToleranceBefore = .zero imageGenerator.requestedTimeToleranceAfter = .zero @@ -578,7 +578,7 @@ public extension AVAsset { } func thumbnailImage(currentTime: CMTime, handler: @escaping (CGImage?) -> Void) { - let imageGenerator = ceateImageGenerator() + let imageGenerator = createImageGenerator() imageGenerator.requestedTimeToleranceBefore = .zero imageGenerator.requestedTimeToleranceAfter = .zero imageGenerator.generateCGImagesAsynchronously(forTimes: [NSValue(time: currentTime)]) { _, cgImage, _, _, _ in diff --git a/Sources/KSPlayer/Core/Utility.swift b/Sources/KSPlayer/Core/Utility.swift index 841f498a6..d0ee84f71 100644 --- a/Sources/KSPlayer/Core/Utility.swift +++ b/Sources/KSPlayer/Core/Utility.swift @@ -160,7 +160,7 @@ extension AVAsset { public func generateGIF(beginTime: TimeInterval, endTime: TimeInterval, interval: Double = 0.2, savePath: URL, progress: @escaping (Double) -> Void, completion: @escaping (Error?) -> Void) { let count = Int(ceil((endTime - beginTime) / interval)) let timesM = (0 ..< count).map { NSValue(time: CMTime(seconds: beginTime + Double($0) * interval)) } - let imageGenerator = ceateImageGenerator() + let imageGenerator = createImageGenerator() let gifCreator = GIFCreator(savePath: savePath, imagesCount: count) var i = 0 imageGenerator.generateCGImagesAsynchronously(forTimes: timesM) { _, imageRef, _, result, error in @@ -189,7 +189,7 @@ extension AVAsset { } } - private func ceateComposition(beginTime: TimeInterval, endTime: TimeInterval) async throws -> AVMutableComposition { + private func createComposition(beginTime: TimeInterval, endTime: TimeInterval) async throws -> AVMutableComposition { let compositionM = AVMutableComposition() let audioTrackM = compositionM.addMutableTrack(withMediaType: .audio, preferredTrackID: kCMPersistentTrackID_Invalid) let videoTrackM = compositionM.addMutableTrack(withMediaType: .video, preferredTrackID: kCMPersistentTrackID_Invalid) @@ -212,8 +212,8 @@ extension AVAsset { return compositionM } - func ceateExportSession(beginTime: TimeInterval, endTime: TimeInterval) async throws -> AVAssetExportSession? { - let compositionM = try await ceateComposition(beginTime: beginTime, endTime: endTime) + func createExportSession(beginTime: TimeInterval, endTime: TimeInterval) async throws -> AVAssetExportSession? { + let compositionM = try await createComposition(beginTime: beginTime, endTime: endTime) guard let exportSession = AVAssetExportSession(asset: compositionM, presetName: "") else { return nil } @@ -225,7 +225,7 @@ extension AVAsset { func exportMp4(beginTime: TimeInterval, endTime: TimeInterval, outputURL: URL, progress: @escaping (Double) -> Void, completion: @escaping (Result) -> Void) throws { try FileManager.default.removeItem(at: outputURL) Task { - guard let exportSession = try await ceateExportSession(beginTime: beginTime, endTime: endTime) else { return } + guard let exportSession = try await createExportSession(beginTime: beginTime, endTime: endTime) else { return } exportSession.outputURL = outputURL await exportSession.export() switch exportSession.status { diff --git a/Sources/KSPlayer/MEPlayer/AVFoundationExtension.swift b/Sources/KSPlayer/MEPlayer/AVFoundationExtension.swift index 040bac7c0..456a748e1 100644 --- a/Sources/KSPlayer/MEPlayer/AVFoundationExtension.swift +++ b/Sources/KSPlayer/MEPlayer/AVFoundationExtension.swift @@ -22,7 +22,7 @@ extension OSType { } extension CVPixelBufferPool { - static func ceate(width: Int32, height: Int32, bytesPerRowAlignment: Int32, pixelFormatType: OSType, bufferCount: Int = 24) -> CVPixelBufferPool? { + static func create(width: Int32, height: Int32, bytesPerRowAlignment: Int32, pixelFormatType: OSType, bufferCount: Int = 24) -> CVPixelBufferPool? { let sourcePixelBufferOptions: NSMutableDictionary = [ kCVPixelBufferPixelFormatTypeKey: pixelFormatType, kCVPixelBufferWidthKey: width, diff --git a/Sources/KSPlayer/MEPlayer/Resample.swift b/Sources/KSPlayer/MEPlayer/Resample.swift index 12a3eac74..5c7cea92e 100644 --- a/Sources/KSPlayer/MEPlayer/Resample.swift +++ b/Sources/KSPlayer/MEPlayer/Resample.swift @@ -114,7 +114,7 @@ class VideoSwresample: FrameChange { // AV_PIX_FMT_VIDEOTOOLBOX格式是无法进行swscale的 imgConvertCtx = sws_getCachedContext(imgConvertCtx, width, height, self.format, dstWidth, dstHeight, dstFormat, SWS_FAST_BILINEAR, nil, nil, nil) } - pool = CVPixelBufferPool.ceate(width: dstWidth, height: dstHeight, bytesPerRowAlignment: linesize, pixelFormatType: pixelFormatType) + pool = CVPixelBufferPool.create(width: dstWidth, height: dstHeight, bytesPerRowAlignment: linesize, pixelFormatType: pixelFormatType) } func transfer(frame: AVFrame) -> PixelBufferProtocol? {