Commit bfd1677d authored by yuzheng's avatar yuzheng

优化视频导出的一些细节

parent 3a7d7262
...@@ -587,11 +587,6 @@ static dispatch_once_t onceToken; ...@@ -587,11 +587,6 @@ static dispatch_once_t onceToken;
NSDateFormatter *formater = [[NSDateFormatter alloc] init]; NSDateFormatter *formater = [[NSDateFormatter alloc] init];
[formater setDateFormat:@"yyyy-MM-dd-HH:mm:ss-SSS"]; [formater setDateFormat:@"yyyy-MM-dd-HH:mm:ss-SSS"];
NSString *outputPath = [NSHomeDirectory() stringByAppendingFormat:@"/tmp/video-%@.mp4", [formater stringFromDate:[NSDate date]]]; NSString *outputPath = [NSHomeDirectory() stringByAppendingFormat:@"/tmp/video-%@.mp4", [formater stringFromDate:[NSDate date]]];
if (videoAsset.URL && videoAsset.URL.lastPathComponent) {
outputPath = [outputPath stringByReplacingOccurrencesOfString:@".mp4" withString:[NSString stringWithFormat:@"-%@", videoAsset.URL.lastPathComponent]];
}
// NSLog(@"video outputPath = %@",outputPath);
session.outputURL = [NSURL fileURLWithPath:outputPath];
// Optimize for network use. // Optimize for network use.
session.shouldOptimizeForNetworkUse = true; session.shouldOptimizeForNetworkUse = true;
...@@ -607,7 +602,12 @@ static dispatch_once_t onceToken; ...@@ -607,7 +602,12 @@ static dispatch_once_t onceToken;
return; return;
} else { } else {
session.outputFileType = [supportedTypeArray objectAtIndex:0]; session.outputFileType = [supportedTypeArray objectAtIndex:0];
if (videoAsset.URL && videoAsset.URL.lastPathComponent) {
outputPath = [outputPath stringByReplacingOccurrencesOfString:@".mp4" withString:[NSString stringWithFormat:@"-%@", videoAsset.URL.lastPathComponent]];
}
} }
// NSLog(@"video outputPath = %@",outputPath);
session.outputURL = [NSURL fileURLWithPath:outputPath];
if (![[NSFileManager defaultManager] fileExistsAtPath:[NSHomeDirectory() stringByAppendingFormat:@"/tmp"]]) { if (![[NSFileManager defaultManager] fileExistsAtPath:[NSHomeDirectory() stringByAppendingFormat:@"/tmp"]]) {
[[NSFileManager defaultManager] createDirectoryAtPath:[NSHomeDirectory() stringByAppendingFormat:@"/tmp"] withIntermediateDirectories:YES attributes:nil error:nil]; [[NSFileManager defaultManager] createDirectoryAtPath:[NSHomeDirectory() stringByAppendingFormat:@"/tmp"] withIntermediateDirectories:YES attributes:nil error:nil];
......
...@@ -584,7 +584,7 @@ ...@@ -584,7 +584,7 @@
_selectedPhotos = [NSMutableArray arrayWithArray:@[coverImage]]; _selectedPhotos = [NSMutableArray arrayWithArray:@[coverImage]];
_selectedAssets = [NSMutableArray arrayWithArray:@[asset]]; _selectedAssets = [NSMutableArray arrayWithArray:@[asset]];
// open this code to send video / 打开这段代码发送视频 // open this code to send video / 打开这段代码发送视频
[[TZImageManager manager] getVideoOutputPathWithAsset:asset presetName:AVAssetExportPreset640x480 success:^(NSString *outputPath) { [[TZImageManager manager] getVideoOutputPathWithAsset:asset presetName:AVAssetExportPresetLowQuality success:^(NSString *outputPath) {
// NSData *data = [NSData dataWithContentsOfFile:outputPath]; // NSData *data = [NSData dataWithContentsOfFile:outputPath];
NSLog(@"视频导出到本地完成,沙盒路径为:%@",outputPath); NSLog(@"视频导出到本地完成,沙盒路径为:%@",outputPath);
// Export completed, send video here, send by outputPath or NSData // Export completed, send video here, send by outputPath or NSData
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment