短片视频修剪器UI

短片视频修剪器用户界面

版本 许可证 平台

若要运行示例项目,请克隆存储库,然后首先从示例目录运行。pod install

修剪

Requirements

  • iOS 9.0+
  • Interoperability with Swift 5.0+

Installation

CocoaPods

ShortClipVideoTrimmerUI is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ShortClipVideoTrimmerUI'

Usage

⚠️ This library doesn’t provide any Trimming Implementations. It has just provided the UI with video frames. You’ll get trimming area (means trimming start time and trimming finish time) and then you can do anything with these informations.

Trimming

Create an instance (in interface builder or through code) of the and add it to your view hierarchy.ShortClipVideoTrimmerContentView

    shortClipTrimmerContentView.delegate = self // shortClipTrimmerContentView is an instance of ShortClipVideoTrimmerContentView
    shortClipTrimmerContentView.startOperation(asset: asset, maxTrimmingDuration: maxTrimmingDuration, numberOfFramesPerCycle: numberOfFramesPerCycle)

Here is type of AVAsset. You have to specify how much maximum trimming duration (which is ) you need and how many frames should be shown per cycle (which is ). Then create a AVPlayer or something releated to AVPlayer. provide a timer which transferes current time of running Video. For exampleassetmaxTrimmingDurationnumberOfFramesPerCycle

// videoPlayer is an instance of AVPlayer
videoPlayer.addPeriodicTimeObserver(forInterval: CMTime(seconds: 0.01, preferredTimescale: 600), queue: .main) {  _ in
    
    shortClipTrimmerContentView.updatePositionBarConstraint(cmTime: videoPlayer.currentTime())
}

you can also customize the by changing it’s color and width’s of subcomponents.ShortClipVideoTrimmerContentView

shortClipTrimmerContentView.updateHandlerWidth(width : 10.0)
shortClipTrimmerContentView.updateKnobWidth(width : 3.0)
shortClipTrimmerContentView.updatePositionBarWidth(width : 4.0)
shortClipTrimmerContentView.updateTrimmingAreaBorderWidth(width : 2.0)
shortClipTrimmerContentView.handlerColor(color : UIColor.blue)
shortClipTrimmerContentView.updateTrimmingAreaBorderColor(color : UIColor.blue)
shortClipTrimmerContentView.updateKnobColor(color : UIColor.white)
shortClipTrimmerContentView.updatePositionBarColor(color : UIColor.white)
shortClipTrimmerContentView.updateTrimmingOutsideBackgroundColor(color : UIColor.white)
shortClipTrimmerContentView.updateTrimmingOutsideMaskAlpha(alpha : 0.5)   
    

By conforming you’ll get the information about when trimming start and end position is changed. For better understanding please see the example project.ShortClipVideoTrimmerContentViewDelegate

Author

Sagar Chandra Das, sagarthecoder@gmail.com

License

ShortClipVideoTrimmerUI is available under the MIT license. See the LICENSE file for more info.

GitHub

点击跳转