Splime 1.0.1

Splime 1.0.1

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2016年1月
SPM支持 SPM

remi robert 维护。



Splime 1.0.1

Splime 是一个工具,让您能够 将视频拆分成帧。同时,它还允许您收集有关视频本身的一些信息。Splime 使用 AVFoundation 框架。

使用 🛠

Splime 会返回一个完成块: (images: [UIImage]) -> (),让您获取拆分后的帧。还有一个可选的进度块: ((progress: Float) -> ())?,用于跟踪拆分器的进度。

videoSpliter = Splime(url: stringPath)
videoSpliter.split({ (images) -> () in
    //use the [UIImage], images frames            
  }, progressBlock: { (progress) -> () in
    print("current progress : [\(progress)]")
})

视频信息📊

Splime 收集与视频相关的一些信息。同样地,您可以用于执行此类操作。您可以收集视频中的帧的总数、总时长(以秒为单位)、每帧的时间等。当您使用有效视频的 URL 初始化新的 Splime 对象,或设置新的 URL 时,Splime 会填充一个结构体,其中包含所有这些信息。所有这些信息都是为了安全起见而只读的。⚠️因为它们在拆分方法中使用。

videoSpliter = Splime(url: stringPath)
//Informations collected

videoSpliter.url = stringPath2
//new Informations collected

//get informations:
videoSpliter.assetInformations.timeScale
videoSpliter.assetInformations.timeValuePerFrame
videoSpliter.assetInformations.totalFrames
videoSpliter.assetInformations.totalSeconds
videoSpliter.assetInformations.frameRate

配置 ⚙

Splime 允许您配置帧分离的方式。您可以指定以下内容:

  • A 时间间隔,例如从 4 秒拆分到 15 秒的视频。
  • 您想要的最大帧数(我想要最多 60 帧,无论如何都行
  • 每个间隔的帧数。例如,我想每 10 帧取一帧。
//For the time interval, CMTime is used, to let you use, a very high precision.
//You can use the same timeScale as the video, avalaible in the video information.
//Split the frames from the 4 secondes, to the 10 secondes.
videoSpliter.startInterval = CMTimeMake(4, videoSpliter.assetInformations.timeScale)
videoSpliter.endInterval = CMTimeMake(10, videoSpliter.assetInformations.timeScale)

//Keep only one frame, every 5.
videoSpliter.everyFrames = 5

//Keep only 35 maximum frames.
//Can be used to limit the memory usage, if the video can.
videoSpliter.totalFrames = 35