A set of tools to trim, crop and select frames inside a video
A set of tools written in swift to crop and trim videos.
To run the example project, clone the repo, and run
pod installfrom the Example directory first.
PryntTrimmerView requires iOS9: It uses Layout Anchors to define the constraints.
Add the following to your Package.swift file
dependencies: [ .package(url: "https://github.com/HHK1/PryntTrimmerView.git", .upToNextMajor(from: "4.0.1")) ]
PryntTrimmerView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "PryntTrimmerView"
Then, run
pod installto download the source and add it to your workspace.
PryntTrimmmerView is available through Carthage. To install it, simply add the following line to your Cartfile:
github "HHK1/PryntTrimmerView"
Run
carthage updateto build the framework and drag the built PryntTrimmerView.framework into your Xcode project.
:warning: This library does not contain an API to crop or trim your video asset. You can find a possible implementation for this in the example pod, but the library only provides the UI.
Create a
TrimmerViewinstance (in interface builder or through code), and add it to your view hierarchy.
trimmerView.asset = asset trimmerView.delegate = self
Access the
startTimeand
endTimeproperty to know where to trim your asset. You can use the
TrimmerViewDelegateto link the trimmer with an
AVPlayerand provide the end user with a preview. See the
VideoTrimmerViewControllerinside the project to see an example.
You can also customize the trimmer view by changing its colors:
trimmerView.handleColor = UIColor.white trimmerView.mainColor = UIColor.orange trimmerView.positionBarColor = UIColor.white
Create an instance of the
VideoCropViewand add it to your view hierarchy, then load your video into the crop view:
videoCropView.asset = asset.
You can set the aspect ratio you want using the
setAspectRatiomethod. Once you are satisfied with the portion of the asset you want to crop, call
getImageCropFrameto retrieve the select frame. See the
VideoCropperViewControllerin the example app for an actual example of how to crop the video for export.
PryntTrimmerView is available under the MIT license. See the LICENSE file for more info.