Latest 0.2.6
Homepage https://github.com/zangqilong198812/YGCTrimVideoView
License MIT
Platforms ios 9.0
Frameworks AVFoundation
Authors

Objective-CPlatform: iOSXCode 9+iOS 11Licence MIT

A wechat like video trim time view.

Features

  • [x] left and right time control
  • [x] custom your left side bar and right
  • [x] support setup maximum duration and minimum duration
  • [x] export video file from your time crop setting

Looks like

Usage

Initialize

    NSString *path = [[NSBundle mainBundle] pathForResource:@"videoName"
                                                     ofType:@"MP4"];
    YGCTrimVideoView *ygcTrimView = [[YGCTrimVideoView alloc] initWithFrame:CGRectMake(0, 75, self.view.bounds.size.width, 80)
                                                       assetUR:[NSURL fileURLWithPath:path]];
    [self.view addSubview:self.ygcTrimView];

or pass the asset to YGCTrimVideoView directly.It has different initialize method.

Make custom UI

- (id)initWithFrame:(CGRect)frame
   leftControlImage:(UIImage *)leftImage
  rightControlImage:(UIImage *)rightImage
   centerRangeImage:(UIImage *)centerImage
       sideBarWidth:(CGFloat)sidebarWidth;
  • leftImage you could setup your left sidebar with a image
  • rightImage same as leftImage
  • centerRangeImage the border image around the slider, maybe required set the image’s resize inset
  • sideBarWidth the control bar width

Setup maximum duration and minimum duration

just setup the property maxSeconds and minSeconds.

// min duration is 2 and max duration is 10 
self.ygcTrimView.minSeconds = 2;
self.ygcTrimView.maxSeconds = 10;

Preview the cropped video

in the delegate funtion

- (void)dragActionEnded:(AVMutableComposition *)asset

every time your finished dragging the control bar
YGCTrimView will generate a AVMutableCompsition.You could create a AVPlayer and play the composition directly.
like

- (void)dragActionEnded:(AVMutableComposition *)asset {
  self.playerItem = [[AVPlayerItem alloc] initWithAsset:asset];
  [self.player replaceCurrentItemWithPlayerItem:self.playerItem];
  [self.player play];

}

Export Video

YGCTrimVideoView support two ways to export a video file.
First Method

- (void)dragActionEnded:(AVMutableComposition *)asset;

get a AVMutableComposition from the delegate function. An AVMutableComposition is an AVAsset.So you could use AVExportSession to export a video file from AVMutableComposition.

Second Method

- (void)exportVideo:(YGCExportFinished)finishedBlock;

you could use the function directly to export a video file .The finishedBlock will give you the video url that from the sandbox.

Installing

Cocoapods

In your podfile.
pod 'YGCTrimVideoView', '~> 0.2.6'
then pod install
if you get an error " Unable to satisfy the following requirements", please use
pod install --repo-update

Requirements

  • iOS 10 or higher

Authors

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

License

This project is licensed under the MIT License.

Latest podspec

{
    "name": "YGCTrimVideoView",
    "version": "0.2.6",
    "summary": "A wechat like video editor view.",
    "description": "A wechat like video editor view. You could setup the maximum duration of a video and the minimum duration of a video.nAlso include the function of custom your time slider view.",
    "homepage": "https://github.com/zangqilong198812/YGCTrimVideoView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "zangqilong": "[email protected]"
    },
    "source": {
        "git": "https://github.com/zangqilong198812/YGCTrimVideoView.git",
        "tag": "0.2.6"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "YGCTrimVideoView/Classes/*.{h,m,c}",
    "resources": "YGCTrimVideoView/Assets/defaultImage.bundle",
    "public_header_files": "YGCTrimVideoView/Classes/*.h",
    "frameworks": "AVFoundation"
}

Pin It on Pinterest

Share This