Giter Site home page Giter Site logo

videoconverter's Introduction

VideoConverter

CI Status Version License Platform Swift 5.0

Introduce

Video can be cropped by x, y, width, and height, and can be rotated 0, 90, 180, 270 degrees. And you can adjust the duration of video playback with startTime and endTime or durationTime, and you can also mute mode.


VideoConverter

- - -
Trim Crop Rotate

Requirements

Installation

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

pod 'VideoConverter'

Usage

import VideoConverter
let videoConverter = VideoConverter(asset: asset)
videoConverter.convert { (url, error) in
    
}

convert

videoConverter.convert(<#T##option: ConverterOption?##ConverterOption?#>, progress: <#T##((Double?) -> Void)?##((Double?) -> Void)?##(Double?) -> Void#>, completion: <#T##((URL?, Error?) -> Void)##((URL?, Error?) -> Void)##(URL?, Error?) -> Void#>)
var videoConverterCrop: ConverterCrop?
if let dimFrame = self.videoView.dimFrame {
    videoConverterCrop = ConverterCrop(frame: dimFrame, contrastSize: self.videoView.videoRect.size)
}

videoConverter.convert(ConverterOption(
    trimRange: CMTimeRange(start: self.videoTrim.startTime, duration: self.videoTrim.durationTime),
    convertCrop: videoConverterCrop,
    rotate: CGFloat(.pi/2 * self.rotate),
    quality: self.preset,
    isMute: self.isMute), progress: { [weak self] (progress) in
        self?.progressView.setProgress(Float(progress ?? 0), animated: false)
}, completion: { [weak self] (url, error) in
    if let error = error {
        let alertController = UIAlertController(title: nil, message: error.localizedDescription, preferredStyle: .alert)
        alertController.addAction(UIAlertAction(title: "Confirm", style: .default, handler: nil))
        self?.present(alertController, animated: true)
    } else {
        self?.convertVideoView.url = url
        self?.progressView.setProgress(0, animated: false)
    }
})

ConverterOption

var trimRange: CMTimeRange // Start time and end time or start time and duration time
var convertCrop: ConverterCrop // Crop position, size
var rotate: CGFloat // radian rotation
var quality: String // Video quality
var isMute: Bool // Mute mode

ConverterCrop

var frame: CGRect // Crop position, size
var contrastSize: CGSize // Crop reference size

Author

pikachu987, [email protected]

License

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

videoconverter's People

Contributors

pikachu987 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.