ImgVidData =[[NSData alloc]init];
ALAssetRepresentation *representation = alAsset.defaultRepresentation;
NSURL *movieURL = representation.url;
NSURL *uploadURL = [NSURL fileURLWithPath:[[NSTemporaryDirectory() stringByAppendingPathComponent:@"test"] stringByAppendingString:@".mov"]];
// ImgVidData = [NSData dataWithContentsOfFile: [[NSTemporaryDirectory() stringByAppendingPathComponent:@"test"] stringByAppendingString:@".mp4"]];
AVAsset *asset = [AVURLAsset URLAssetWithURL:movieURL options:nil];
AVAssetExportSession *session =
[AVAssetExportSession exportSessionWithAsset:asset presetName:AVAssetExportPresetMediumQuality];
session.outputFileType = AVFileTypeQuickTimeMovie;
session.outputURL = uploadURL;
videoURL=uploadURL;
[session exportAsynchronouslyWithCompletionHandler:^{
if (session.status == AVAssetExportSessionStatusCompleted)
{
NSLog(@"output Video URL %@",uploadURL);
}
}];
ImgVidData = [NSData dataWithContentsOfURL:session.outputURL];
以上是代码,我在 didFinishPickingAssets:(NSArray *)assets 内部实现
我正在拾取视频并将视频上传到服务器。我正在获取上传的视频 URL 并将其转换为 NSdata 并将其上传到服务器。
奇怪:每次我将相同的视频上传到我第一次选择的服务器时。我每次都选择不同的视频,但相同的视频会被上传。任何帮助!