EOExportManager类为所有导出相关接口调用。(具体接口参考下方介绍)
初始化EOExportManager,去使用下方所有接口调用。
参数说明
参数名 | 参数类型 | 参数说明 | 来源 |
---|---|---|---|
model | EOExportModel * | 初始化导出相关视频数据信息model | sdk回调 |
代码示例
[[EOExportManager alloc] initWithExportModel:self.model]
返回值
获取到EOExportManager实例,下面接口请求使用。
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
videoSize | CGSize | 视频宽高 |
方法定义
- (void)getVideoCoverImage:(CGSize)videoSize success:(nullable void(^)(UIImage *draftImg, UIImage *videoImg, int64_t videoFrameTime, NSString *coverType))completionBlock
代码示例
[self.manager getVideoCoverImage:self.model.originRatioSize success:^(UIImage * _Nonnull draftImg, UIImage * _Nonnull videoImg, int64_t videoFrameTime, NSString * _Nonnull coverType) { self.videoFrameTime = videoFrameTime; if ([coverType isEqualToString:@"image"]) { self.isCoverImage = YES; } if (draftImg) { self.coverView.image = draftImg; self.coverImg = draftImg; } else { self.coverView.image = videoImg; self.coverImg = videoImg; } }];
返回值completionBlock
回调
参数名 | 参数类型 | 参数说明 |
---|---|---|
draftImg | UIImage | 草稿封面图 |
videoImg | UIImage | 视频帧封面图 |
videoFrameTime | int64_t | 视频帧封面图所在时间 |
coverType | NSString | 封面类型: |
方法定义
- (void)setCanvasSize;
代码示例
[self.manager setCanvasSize];
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
preview | UIView | 需要展示视频的父View |
方法定义
- (void)resetPlayeView:(UIView *)preview;
代码示例
CGFloat ratio = [self.manager getVideoSize].width/[self.manager getVideoSize].height; CGFloat previewViewHeight = EO_ScreenHeight() * 445.0/812.0; CGFloat newHeight = ratio>1 ? EO_ScreenWidth()/ratio : previewViewHeight; CGFloat newWidth = ratio>1 ? EO_ScreenWidth() : newHeight*ratio; CGFloat newX = (EO_ScreenWidth()-newWidth)/2; CGFloat newY = EO_NavBarHeight()+48+(previewViewHeight-newHeight)/2; self.previewView = [[UIView alloc] initWithFrame:CGRectMake(newX, newY, newWidth, newHeight)]; [self.view addSubview:self.previewView]; [self.manager resetPlayeView:self.previewView];
方法定义
- (void)pause;
代码示例
[self.manager pause];
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
videoFrameTime | int64_t | 设置视频时间 |
isSmooth | BOOL | 是否光滑滑动 |
方法定义
- (void)setVideoRatioTime:(int64_t)videoFrameTime isSmooth:(BOOL)isSmooth;
代码示例
[self.manager setVideoRatioTime:0 isSmooth:NO];
方法定义
- (CGSize)getVideoSize;
代码示例
CGFloat ratio = [self.manager getVideoSize].width/[self.manager getVideoSize].height;
返回值
返回类型 | 参数说明 |
---|---|
CGSize | 视频分辨率宽高 |
方法定义
- (void)exportVideoWithProgress:(void (^_Nullable )(CGFloat progress))progressBlock resultBlock:(void (^)(NSError *error,id result))exportBlock;
代码示例
[self.manager exportVideoWithProgress:^(CGFloat progress) { @strongify(self) NSLog(@"%.2f",progress); self.videoSlider.value = progress/100; self.progressLabel.text = [NSString stringWithFormat:@"%.f%@",progress,@"%"]; [self.progressLabel mas_updateConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.videoSlider.mas_left).offset(self.videoSlider.frame.size.width*progress/100-17); }]; } resultBlock:^(NSError * _Nonnull error, id _Nonnull result) { @strongify(self) [self restoreState]; if (error || !result) { if ([error.domain isEqualToString:@"cancelProcess"]) { [self.view makeToast:EOExportUILocalization(@"eo_export_import_cancel_export_tip") duration:1.5f position:CSToastPositionCenter]; } else { [self.view makeToast:EOExportUILocalization(@"eo_export_import_error") duration:1.5f position:CSToastPositionCenter]; } } else { NSURL *filePath = result; if (self.delegate && [self.delegate respondsToSelector:@selector(exportVideoPath:videoImage:)]) { [self.delegate exportVideoPath:filePath.path videoImage:self.coverView.image]; [self restoreState]; } else { [self.view makeToast:EOExportUILocalization(@"eo_export_import_success") duration:1.5f position:CSToastPositionCenter]; UISaveVideoAtPathToSavedPhotosAlbum(filePath.path, self, @selector(video:didFinishSavingWithError:contextInfo:), nil); } } }];
返回值progressBlock
回调
参数名 | 参数类型 | 参数说明 |
---|---|---|
progress | CGFloat | 导出视频进度 |
exportBlock
回调
参数名 | 参数类型 | 参数说明 |
---|---|---|
error | NSError | 导出失败信息 |
result | id | 导出成功信息 |
方法定义
- (void)cancelExport;
代码示例
[self.manager cancelExport];
参数说明
参数名 | 参数类型 | 参数说明 | 备注 |
---|---|---|---|
coverImg | UIImage | 封面图片 | |
videoFrameTime | int64_t | 视频帧的时间位置 | 如果是相册图片为0 |
type | int | 封面图类型 | 1:相册图片类型 |
方法定义
- (void)saveCoverImage:(UIImage *)coverImg time:(int64_t)videoFrameTime canvasType:(int)type;
代码示例
self.manager saveCoverImage:self.coverView.image time:self.videoFrameTime canvasType:self.isCoverImage ? 1: 2];
方法定义
- (NSArray *)exportFPSTitleArr;
代码示例
[self.manager exportFPSTitleArr];
方法定义
- (NSArray *)exportPresentTitleArr;
代码示例
[self.manager exportPresentTitleArr];
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
index | NSInteger | FPS数组下标 |
方法定义
- (void)setExportFPSSelectIndex:(NSInteger)index;
代码示例
[self.manager setExportFPSSelectIndex:fpsIndex];
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
index | NSInteger | 分辨率数组下标 |
方法定义
- (void)setExportPresentSelectIndex:(NSInteger)index;
代码示例
[self.manager setExportPresentSelectIndex:resolutionIndex];
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
atTime | NSTimeInterval | 视频抽帧的时间 |
size | CGSize | 视频分辨率尺寸 |
isLastImage | BOOL | 多次调用的时候标记最后一个 |
方法定义
- (void)getProcessedPreviewImageAtTime:(NSTimeInterval)atTime preferredSize:(CGSize)size isLastImage:(BOOL)isLastImage compeletion:(void (^)(UIImage *image, NSTimeInterval atTime))compeletion;
代码示例
CGFloat ratioTime = self.videoFrameTime * 1.0 / USEC_PER_SEC; @weakify(self); [self.manager getProcessedPreviewImageAtTime:ratioTime preferredSize:[self.manager getVideoSize] isLastImage:NO compeletion:^(UIImage * _Nonnull image, NSTimeInterval atTime) { @strongify(self); !self.onDismiss ?: self.onDismiss(image, self.videoFrameTime,NO); [self dismissViewControllerAnimated:YES completion:nil]; }];
返回值compeletion
回调
参数名 | 参数类型 | 参数说明 |
---|---|---|
image | UIImage | 抽帧成功图片 |
atTime | NSTimeInterval | 抽帧的时间 |
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
atTimes | NSArray | 视频抽帧的时间数组 |
size | CGSize | 视频分辨率尺寸 |
withEffect | BOOL | 是否带特效 |
方法定义
- (void)getPreviewImages:(NSArray *)atTimes preferredSize:(CGSize)size withEffect:(BOOL)withEffect frameBlock:(void (^)(UIImage *image, NSTimeInterval atTime))frameBlock;
代码示例
CGSize size = self.previewView.frame.size; NSTimeInterval durationStep = [self.manager totalVideoDuration] / 12; NSMutableArray *timeArray = [NSMutableArray arrayWithCapacity:0]; for (NSInteger index = 0; index < 12; index++) { [timeArray addObject:[NSNumber numberWithFloat:durationStep * index]]; } @weakify(self); [self.manager getPreviewImages:[timeArray copy] preferredSize:size withEffect:YES frameBlock:^(UIImage * _Nonnull image, NSTimeInterval atTime) { @strongify(self); if (image) { [self.frames addObject:image]; if (self.frames.count == 12) { [self.pickerView updateVideoFrames:self.frames durationRatios:self.durationRatios]; } } }];
返回值frameBlock
回调
参数名 | 参数类型 | 参数说明 |
---|---|---|
image | UIImage | 抽帧成功图片 |
atTime | NSTimeInterval | 抽帧的时间 |
方法定义
//视频抽帧(当前帧) 54- (UIImage *)capturePreviewUIImage;
代码示例
[self.manager capturePreviewUIImage];
返回值
返回类型 | 参数说明 |
---|---|
UIImage | 当前抽帧图片 |
方法定义
- (NSTimeInterval)totalVideoDuration;
代码示例
NSTimeInterval durationStep = [self.manager totalVideoDuration] / 12;
返回值
返回类型 | 参数说明 |
---|---|
NSTimeInterval | 视频时长 |
方法定义
- (void)getPickSingleImageResourceWithCompletion:(nullable void(^)(NSURL * _Nullable pickImage, NSError * _Nullable error, BOOL cancel))completionBlock;
代码示例
[self.manager getPickSingleImageResourceWithCompletion:^(UIImage * _Nullable pickImage, NSError * _Nullable error, BOOL cancel) { @strongify(self); if (pickImage) { [self coverAlbumImageCrop:self.view coverViewImage:pickImage]; } }];
返回值completionBlock
回调
参数名 | 参数类型 | 参数说明 |
---|---|---|
pickImage | NSURL | 相册选取照片的路径 |
error | NSError | 照片选取失败信息 |
cancel | BOOL | 是否点击取消 |
方法定义
- (CGFloat)mainTrackMaxEnd;
代码示例
[self.manager mainTrackMaxEnd]
返回值
返回类型 | 参数说明 |
---|---|
CGFloat | 视频主轨时长 |
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
isCover | BOOL | 是否添加封面 |
方法定义
- (void)shouldAddCover:(BOOL)isCover;
代码示例
[self.manager shouldAddCover:NO];
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
shouldAddWaterMark | BOOL | 是否添加水印 |
方法定义
- (void)shouldAddWaterMark:(BOOL)shouldAddWaterMark;
代码示例
[self.manager shouldAddWaterMark:YES];
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
waterMarkImage | UIImage | 水印image |
方法定义
- (void)addWaterMarkImage:(UIImage *)waterMarkImage;
代码示例
[self.manager addWaterMarkImage:EOExportUIImage(@"eo_export_waterMark")];
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
waterMarkSize | CGSize | 水印大小,计算方式:当前视频分辨率/375*size的宽高 |
方法定义
- (void)setWaterMarkSize:(CGSize)waterMarkSize;
代码示例
CGFloat WaterMarkWidth = 29; CGFloat WaterMarkHeight = 31; switch (self.presentIndex) { case 0: WaterMarkHeight = WaterMarkHeight * (540/375); WaterMarkWidth = WaterMarkWidth * (540/375); break; case 1: WaterMarkHeight = WaterMarkHeight * (720/375); WaterMarkWidth = WaterMarkWidth * (720/375); break; case 2: WaterMarkHeight = WaterMarkHeight * 1080/375; WaterMarkWidth = WaterMarkWidth * (1080/375); break; case 3: WaterMarkHeight = WaterMarkHeight * (2160/375); WaterMarkWidth = WaterMarkWidth * (2160/375); break; default: break; } [self.manager setWaterMarkSize:CGSizeMake(WaterMarkWidth, WaterMarkHeight)];
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
vc | UIViewController | 当前控制器 |
imagePath | NSString | 图片链接 |
方法定义
- (void)pushCropVC:(UIViewController *)vc imagePath:(NSString *)imagePath Completion:(nullable void(^)(NSString *imagePath))completionBlock;
代码示例
[weakSelf.manager getPickSingleImageResourceWithCompletion:^(NSURL * _Nullable pickImage, NSError * _Nullable error, BOOL cancel) { if (pickImage) { [weakSelf.manager pushCropVC:weakSelf imagePath:[pickImage path] Completion:^(NSString * _Nonnull imagePath) { if (imagePath.length) { weakSelf.coverView.image = [UIImage imageWithContentsOfFile:imagePath]; weakSelf.pickerView.isSelectPickAlbumImage = YES; [weakSelf switchPreviewOrPickAlbumImage:YES]; } }]; } }];
返回值
返回类型 | 参数说明 |
---|---|
completionBlock | 裁剪后的图片结果路径 |
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
color | UIColor | 画布颜色 |
方法定义
- (void)setCanvasColor:(UIColor *)color;
代码示例
[self.manager setCanvasColor:[EOExportUIHelper eo_colorWithHex:@"000000"]];
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
metadata | NSDictionary <NSString*,NSString*> | *"com.apple.quicktime.copyright"//AVMetadataCommonKeyCopyrights |
方法定义
- (void)setMetadata:(NSDictionary <NSString*,NSString*> *)metadata;
代码示例
NSDictionary * metadataDict = [[NSDictionary alloc] initWithObjectsAndKeys:@"EffectOne",@"com.apple.quicktime.copyright", nil]; [self.manager setMetadata:metadataDict];
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
completion | void (^)(UIImage * _Nullable image, NSError * _Nullable error) | 导出完成回调 |
方法定义
/// export image - (void)exportImageWithCompletion:(void (^)(UIImage * _Nullable image, NSError * _Nullable error))completion;
代码示例
```objectivec
[self.manager shouldAddWaterMark:YES];
[self.manager addWaterMarkImage:EOExportUIImage(@"eo_export_waterMark")];
[self.manager setWaterMarkSize:self.warterMarkSize];
[self.manager shouldAddCover:NO];
__weak typeof(self) weakSelf = self;
[self.manager exportImageWithCompletion:^(UIImage * _Nullable image, NSError * _Nullable error) { __strong typeof(self) strongSelf = weakSelf; if (error || !image) { [strongSelf.view makeToast:EOExportUILocalization(@"eo_export_save_error") duration:1.5f position:CSToastPositionCenter]; return; } if (strongSelf.delegate && [strongSelf.delegate respondsToSelector:@selector(exportViewController:didExportImage:)]) { [strongSelf.delegate exportViewController:strongSelf didExportImage:image]; [strongSelf restoreState]; } else { [strongSelf saveImageToPhotoLibrary:image]; } }];
## 设置码率 **参数说明** | 参数名 | 参数类型 | 参数说明 | | --- | --- | --- | | biteRate | int | 码率的具体值 | **方法定义** ```objectivec // {zh} 码率设置 {en} Rate setting - (void)setBiteRate:(int)biteRate;
代码示例
[self.manager setBiteRate:2800000];