Giter Club home page Giter Club logo

maxvideo's Introduction

MaxVideo

多张图片合成视频;多个小视频合成大视频;添加静态图片水印;设置视频导出速率;多段音频合成

Usage

导入 HandlerVideo.h

/**
  *  图片合成视频
  *@param videoFullPath 合成路径
  *@param frameImgs 图片数组
  *@param fps 帧率
  *@param progressImageBlock 进度回调
  *@param completedBlock 完成回调
 */
- (void)composesVideoFullPath:(NSString *)videoFullPath
                    frameImgs:(NSArray<UIImage *> *)frameImgs
                          fps:(int32_t)fps
           progressImageBlock:(CompProgressBlcok)progressImageBlock
               completedBlock:(CompCompletedBlock)completedBlock;

/**
 *  多个小视频合成大视频
 *@param subsectionPaths 视频地址数组
 *@param videoFullPath 合成视频路径
 *@param completedBlock 完成回调
 */
- (void)combinationVideosWithVideoPath:(NSArray<NSString *> *)subsectionPaths videoFullPath:(NSString *)videoFullPath completedBlock:(CompFinalCompletedBlock)completedBlock;

/**
 * 将视频分解成图片
 *@param fileUrl 视频路径
 *@param fps 帧率
 *@param splitCompleteBlock 分解完成回调
 */
- (void)splitVideo:(NSURL *)fileUrl fps:(float)fps splitCompleteBlock:(SplitCompleteBlock) splitCompleteBlock;


/**
  视频添加静态图片水印

 @param watermaskImg 水印图片
 @param videoFullPath 合成视频路径
 @param completedBlock 完成回调
 */
- (void)addWatermaskVideoWithWatermaskImg:(UIImage *)watermaskImg inputVideoPath:(NSString *)inputVideoPath outputVideoFullPath:(NSString *)videoFullPath completedBlock:(CompFinalCompletedBlock)completedBlock;


/**
 设置视频导出速率

 @param speedType 速率类型
 @param inputVideoPath 视频源路径
 @param videoFullPath 导出路径
 @param completedBlock 完成回调
 */
- (void)setVideoSpeed:(VideoSpeedType)speedType inputVideoPath:(NSString *)inputVideoPath outputVideoFullPath:(NSString *)videoFullPath completedBlock:(CompFinalCompletedBlock)completedBlock;

导入AudioTool.h 头文件

/**
 音频合并

 @param subsectionPaths 合并路径数组
 @param audioFullPath 导出路径(.m4a格式)
 @param completedBlock 完成回调
 */
+ (void)combinationAudiosWithAudioPath:(NSArray<NSString *> *)subsectionPaths
                         audioFullPath:(NSString *)audioFullPath
                        completedBlock:(CompFinalCompletedBlock)completedBlock;

Example

  • 将视频分解成图片
 if (![[NSFileManager defaultManager] fileExistsAtPath:kSplitImages]) {
        [[NSFileManager defaultManager]createDirectoryAtPath:kSplitImages withIntermediateDirectories:YES attributes:nil error:nil];
    }
    
   // 分解视频
    NSString *path = [[NSBundle mainBundle] pathForResource:@"video1" ofType:@"mp4"];
    [[HandlerVideo sharedInstance] splitVideo:[NSURL fileURLWithPath:path] fps:10 splitCompleteBlock:^(BOOL success, NSMutableArray *splitimgs) {
        if (success && splitimgs.count != 0) {
            NSLog(@"----->> success");
            NSLog(@"---> splitimgs个数:%lu",(unsigned long)splitimgs.count);
        }
    }];

  • 视频合并
    NSString *path1 = [[NSBundle mainBundle] pathForResource:@"video1" ofType:@"mp4"];
    NSString *path2 = [[NSBundle mainBundle] pathForResource:@"video2" ofType:@"mp4"];
    self.conbineVideos = [NSMutableArray arrayWithObjects:path1,path2,nil];
    
    [[HandlerVideo sharedInstance] combinationVideosWithVideoPath:self.conbineVideos videoFullPath:kCombineVideo completedBlock:^(BOOL success, NSString *errorMsg) {
        if (success) {
            NSLog(@"---->  SUCCESS");
        }
    }];

  • 设置视频速率
  // 正常
  self.speedType = VideoSpeedTypeNormal;
  // 快速
  self.speedType = VideoSpeedTypeFast;
  // 慢速
  self.speedType = VideoSpeedTypeSlow;
   
  NSString *path = [[NSBundle mainBundle] pathForResource:@"video1" ofType:@"mp4"];
  __weak typeof(self) WS = self;
  [[HandlerVideo sharedInstance] setVideoSpeed:self.speedType inputVideoPath:path outputVideoFullPath:@"/Users/VS/Desktop/video.mp4" completedBlock:^(BOOL success, NSString *msg) {
        if (success) {
            NSLog(@"---->  SUCCESS");
        } else {
            NSLog(@"---->> %@",msg);
        }
  }];
  • 添加静态图片水印
    __weak typeof(self) WS = self;
    UIImage *waterImg = [UIImage imageNamed:@"paint_watermark.png"];
    NSString *path1 = [[NSBundle mainBundle] pathForResource:@"video1" ofType:@"mp4"];
    [[HandlerVideo sharedInstance] addWatermaskVideoWithWatermaskImg:waterImg inputVideoPath:path1 outputVideoFullPath:@"/Users/VS/Desktop/video.mp4" completedBlock:^(BOOL success, NSString *msg) {
        if (success) {
            NSLog(@"---->  SUCCESS");
        } else {
            NSLog(@"---->> %@",msg);
        }
    }];
  • 音频合并
    NSString *path1 = [[NSBundle mainBundle] pathForResource:@"123" ofType:@"mp3"];
    NSString *path2 = [[NSBundle mainBundle] pathForResource:@"123" ofType:@"mp3"];
    __weak typeof(self) WS = self;
    [AudioTool combinationAudiosWithAudioPath:@[path1, path2] audioFullPath:@"/Users/VS/Desktop/audio.m4a" completedBlock:^(BOOL success, NSString *msg) {
        if (success) {
            NSLog(@"---->  SUCCESS");
        } else {
            NSLog(@"---->> %@",msg);
        }
    }];

maxvideo's People

Contributors

ismilesky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

maxvideo's Issues

多个不同方向的视频合成导出

多个不同方向的视频合成后,导出到本地相册,方向不一致。
请教一下,如何控制每个视频的方向呢?是在循环里设置吗?

合并后的视频黑屏

合并后的视频封面是黑屏 但视频是能够正常播放的 这个问题是偶现的 是什么原因呢

逐帧分解视频内存泄漏

我用一个15秒的视频,分解时候设置为30fps,然后Xcode显示Memory一秒涨20M,等到了几百M的时候内存不足就退了,真机测试。

原本我是swift代码测试,发现有问题,然后再看OC的,代码没变,就换个参数,也不行。

在swift里 我测试发现是将图片提取出来后放到UIImage数组里的时候内存会增加,有什么好的方法可以解决么?

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.