Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Oct 10, 2024
1 parent 37e3720 commit 9cbfcd0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Sources/KSPlayer/AVPlayer/KSAVPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -570,15 +570,15 @@ class AVMediaPlayerTrack: MediaPlayerTrack {
}

public extension AVAsset {
func ceateImageGenerator() -> AVAssetImageGenerator {
func createImageGenerator() -> AVAssetImageGenerator {
let imageGenerator = AVAssetImageGenerator(asset: self)
imageGenerator.requestedTimeToleranceBefore = .zero
imageGenerator.requestedTimeToleranceAfter = .zero
return imageGenerator
}

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
Expand Down
10 changes: 5 additions & 5 deletions Sources/KSPlayer/Core/Utility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand All @@ -225,7 +225,7 @@ extension AVAsset {
func exportMp4(beginTime: TimeInterval, endTime: TimeInterval, outputURL: URL, progress: @escaping (Double) -> Void, completion: @escaping (Result<URL, Error>) -> 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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSPlayer/MEPlayer/AVFoundationExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSPlayer/MEPlayer/Resample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand Down

0 comments on commit 9cbfcd0

Please sign in to comment.