AVAssetExportSession 视频转码
来源:互联网 发布:自学c语言 编辑:程序博客网 时间:2024/06/06 04:40
// 视频转码
- (void) convertVideoWithModel:(NSString *) localVideoPath {
TYWeakify(self, weakSelf);
//转码配置
NSURL *inputURL = [NSURL fileURLWithPath:localVideoPath];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
AVAssetExportSession *exportSession= [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPreset960x540];
exportSession.shouldOptimizeForNetworkUse = YES;
exportSession.outputURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@.mp4",localVideoPath]]; //转码后的视频保存目录
self.liveShareView.localVideoURL = [NSString stringWithFormat:@"%@.mp4",localVideoPath];
exportSession.outputFileType = AVFileTypeMPEG4;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
int exportStatus = exportSession.status;
switch (exportStatus) {
case AVAssetExportSessionStatusFailed: {
NSError *exportError = exportSession.error;
NSLog (@"AVAssetExportSessionStatusFailed: %@", exportError);
break;
}
case AVAssetExportSessionStatusCompleted: {
NSLog(@"视频转码成功");
[weakSelf uploadVideo];
}
}
}];
}
- (void) convertVideoWithModel:(NSString *) localVideoPath {
TYWeakify(self, weakSelf);
//转码配置
NSURL *inputURL = [NSURL fileURLWithPath:localVideoPath];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
AVAssetExportSession *exportSession= [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPreset960x540];
exportSession.shouldOptimizeForNetworkUse = YES;
exportSession.outputURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@.mp4",localVideoPath]]; //转码后的视频保存目录
self.liveShareView.localVideoURL = [NSString stringWithFormat:@"%@.mp4",localVideoPath];
exportSession.outputFileType = AVFileTypeMPEG4;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
int exportStatus = exportSession.status;
switch (exportStatus) {
case AVAssetExportSessionStatusFailed: {
NSError *exportError = exportSession.error;
NSLog (@"AVAssetExportSessionStatusFailed: %@", exportError);
break;
}
case AVAssetExportSessionStatusCompleted: {
NSLog(@"视频转码成功");
[weakSelf uploadVideo];
}
}
}];
}
阅读全文
0 0
- AVAssetExportSession 视频转码
- iOS AVAssetExportSession视频进行转码、裁剪
- iOS 两个视频首尾合并- AVAssetExportSession
- AVAssetExportSession 导出视频无法完成操作
- AVAssetExportSession翻译
- AVAssetExportSession的问题
- AVAssetExportSession progress KVO
- ios AVAssetExportSession的使用完整版
- AVAssetExportSession的exportAsynchronouslyWithCompletionHandler:回调不执行的原因
- 视频转码
- 视频转码
- ffmpeg视频转码
- android 视频转码
- java 视频转码
- 腾讯视频转码
- java 视频转码
- Java视频转码
- FFMPEG视频转码
- Unity Configurable Joint 运行时更改参数
- 按照excel指定的样式导出数据
- ST-Link SWD接口接线
- 寻找主元素
- Training YOLOv2
- AVAssetExportSession 视频转码
- wap页开发笔记
- 几个集合的实现原理简介
- 关于FIFO深度的计算的讨论
- Qt 中文使用小结
- vs,C++Win32项目中,添加运行窗口
- 重叠IO overlapped I/O 运用详解
- Null value was assigned to a property of primitive type setter of
- debian7.1请使用 apt-cdrom,通过它就可以让 APT 能识别该盘片。apt-get upgdate 不能被用来加入新的盘片。