音视频拼接(多个小视频拼接成一个大视频)

2017-11-07  本文已影响127人  SunnyLeong
视频处理

最后的每个小视频通过完成按钮合成一个大视频!一句话调用!可以自定义!

- (void)allConbineVideos{

    //清空一下
    [self.conbineVideos removeAllObjects];
    for (int i=0; i<self.videoModel.video_list.count; i++) {
        EnglishVideoList *videoList = self.videoModel.video_list[i];
        [self.conbineVideos addObject:videoList.dubbing_url_path];
    }
    //存放路径
    NSString *savePath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, true).firstObject;
    NSString *soundVedio = [savePath stringByAppendingPathComponent:@"MJDownload/conbineVideos"];
    if (![[NSFileManager defaultManager] fileExistsAtPath:soundVedio]) {
        [[NSFileManager defaultManager] createDirectoryAtPath:soundVedio withIntermediateDirectories:true attributes:nil error:nil];
    }
    NSString *saveSoundName =  [soundVedio stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mp4",self.videoModel.book_id]];
    //写入model
    self.videoModel.dubbing_all_url_path = saveSoundName;
    NSLog(@"saveSoundName=%@",saveSoundName);
    [[HandlerVideo sharedInstance] combinationVideosWithVideoPath:self.conbineVideos videoFullPath:saveSoundName completedBlock:^(BOOL success, NSString *errorMsg) {//@"/Users/Lenn/Desktop/moive.mp4"
        dispatch_async(dispatch_get_main_queue(), ^{
            if (success) {
                NSLog(@"合成成功SUCCESS");
                //计算平均得星
                CGFloat totalStarNum = 0;
                for (EnglishVideoList *videoList in self.videoModel.video_list) {
                    totalStarNum += [videoList.cloud_star_count floatValue];
                }
                totalStarNum = totalStarNum / self.videoModel.video_list.count;
                totalStarNum = round(totalStarNum);
                self.videoModel.total_star_count = totalStarNum;
                //存储到数据库
             BOOL isOk = [[PublicDataBaseMethod sharedStaticDataBaseManager] updateEnglishVideoList:self.videoModel.sutdent_uuid andBookId:self.videoModel.book_id andDubbingAllUrlPath:self.videoModel.dubbing_all_url_path andTotalStarCount:self.videoModel.total_star_count];
                if (isOk) {
                    NSLog(@"数据库更新成功");
                    //提交-提交成功进入下一页
                    self.hud.labelText = @"数据提交中...";
                    [self.hud hide:YES];

                    //网络上传
                    [self upLoadDubbingVoiceFile];

                }

            } else {
                NSLog(@"合成失败ERROR=%@",errorMsg);
            }
            
        });

    }];
}
上一篇 下一篇

猜你喜欢

热点阅读