VideoTrim
介绍
您可以将每个视频帧作为视频资源提取出图像,并设置开始时间和结束时间。
VideoTrim
- | - |
---|---|
![]() |
![]() |
要求
VideoTrim
用 Swift 5.0 编写,兼容 iOS 8.0+。
安装
VideoTrim 通过 CocoaPods 提供。要安装,只需将以下行添加到您的 Podfile 中
pod 'VideoTrim'
用法
import VideoTrim
let videoTrim = VideoTrim()
self.view.addSubview(videoTrim)
完成!
属性
设置属性
资产
videoTrim.asset = AVAsset(url: url) // After setting the asset, the image frame is extracted.
videoTrim.currentTime = CMTime(value: 0, timescale: 0) // The frame bar position changes with currentTime.
videoTrim.frameImageCount = 20 // Number of frame images
videoTrim.trimReaminWidth = 50 // Video trim minimum length
videoTrim.trimMaximumDuration = CMTime(value: CMTimeValue(6000), timescale: CMTimeScale(600)) // Video trim maximum Time
videoTrim.topMargin = 4 // The top margin of the screen.
videoTrim.bottomMargin = 8 // The bottom margin of the screen.
videoTrim.leadingMargin = 0 // The leading margin of the screen.
videoTrim.trailingMargin = 0 // The trailing margin of the screen.
videoTrim.frameHeight = 48 // The image frame height.
videoTrim.trimMaskDimViewColor = UIColor(white: 0/255, alpha: 0.7) // The color of the screen overlay outside the start time and end time.
videoTrim.trimLineRadius = 4 // The radius of the trim line.
videoTrim.trimLineWidth = 4 // Border width of the trim line.
videoTrim.trimLineViewColor = UIColor.white.cgColor // This is the trim line color.
videoTrim.playLineRadius = 3 // The radius of the play line.
videoTrim.playLineWidth = 6 // This is the border width of the play line.
videoTrim.playLineVerticalSize = 4 // The difference between the height of the play line and the top and bottom of the image frame.
videoTrim.playTimeLineViewColor = UIColor.white // This is the play time line color.
videoTrim.timeColor = UIColor.white // time text color.
videoTrim.timeFont = UIFont.systemFont(ofSize: 15) // time text font.
videoTrim.startTime = CMTime(value: 600, timescale: 600) // CMTime of start time.
videoTrim.endTime = CMTime(value: 1200, timescale: 600) // CMTime of end time.
videoTrim.durationTime = CMTime(value: 1200, timescale: 600) // CMTime from start time to end time.
获取属性
videoTrim.playTime // CMTime of PlayTime.
videoTrim.startTime // CMTime of start time.
videoTrim.endTime // CMTime of end time.
videoTrim.durationTime // CMTime from start time to end time.
委派
class ViewController: UIViewController{
override func viewDidLoad() {
super.viewDidLoad()
let videoTrim = VideoTrim()
videoTrim.delegate = self
}
}
// MARK: VideoTrimDelegate
extension ViewController: VideoTrimDelegate {
func videoTrimStartTrimChange(_ videoTrim: VideoTrim) { // It is called when you touch the start time, end time, and play time.
}
func videoTrimEndTrimChange(_ videoTrim: VideoTrim) { // Called at the end of touch start time, end time and play time.
}
func videoTrimPlayTimeChange(_ videoTrim: VideoTrim) { // Called when touching the start time, end time and play time.
}
}
作者
pikachu987, [email protected]
许可
VideoTrim遵循MIT许可。请参阅LICENSE文件了解更多信息。