Giter Club home page Giter Club logo

videoeditor's Introduction

VideoEditor

A lightweight video editor without UI. See VideoEditorKit for the version with UI

Requirements

  • iOS 13
  • Combine

Features

  • Adjust speed rate
  • Crop using presets
  • Trim begining and end

How to use

Generate an AVPlayerItem

Create and configure a video edit object.

var edit = VideoEdit()
edit.isMuted = true
edit.speedRate = 0.5
edit.croppingPreset = .landscape
edit.trimPositions = (
    CMTime(value: 2, timescale: 1),
    CMTime(value: 6, timescale: 1)
)

Ask the video editor to apply these videos edits to a specific asset and

editor.apply(edit: videoEdit, to: asset)
    .map { result -> AVPlayerItem? in
        let item = AVPlayerItem(asset: result.asset)
        item.videoComposition = result.videoComposition
        return item
    }
    .replaceError(with: nil)
    .sink { [weak self] item in
        self?.player.replaceCurrentItem(with: item)
    }

Export to URL

editor.apply(edit: videoEdit, to: asset)
    .flatMap { result in
        result.export(to: outputUrl)
    }.sink { result in
        print("Failed to save edited video at \(outputUrl.path). Error: \(result)")
    } receiveValue: { _ in
        print("Successfully saved edited video at \(outputUrl.path)")
    }

Video Editing Capabilities

Property Type Default Description
isMuted Bool false Mutes the edited video if set to true
speedRate Double 1.0 Defines the speed ratio of the edited video. (e.g. 2.0 will result in an edited video played twice as fast)
trimPositions (CMTime, CMTime)? nil Defines the times where the video should start and end
croppingPreset CroppingPreset? nil Defines the cropping preset to apply to the edit video. See CroppingPreset

Cropping Presets

Preset Width / Height
vertical 3/4
standard 4/3
portrait 9/16
square 1/1
landscape 16/9
instagram 4/5

To do

  • Tests
  • Cropping (custom width/height ratio)

videoeditor's People

Contributors

titouanvanbelle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.