我正在尝试上传视频。我已将视频文件保存为MP4文件,如下所示:
NSString *fileName = [NSString stringWithFormat:@"chatVideo-%d.mp4",arc4random()%1000];
NSString *myPathDocs = [documentsDirectory stringByAppendingPathComponent:fileName];
NSURL *videoURL = [NSURL fileURLWithPath:myPathDocs];
AVAssetExportSession *exportSession = [AVAssetExportSession exportSessionWithAsset:asset2 presetName:AVAssetExportPresetHighestQuality];
exportSession.outputURL = videoURL;
exportSession.outputFileType = AVFileTypeMPEG4;
NSData *videodata =[NSData dataWithContentsOfURL:videoURL];
我将图API称为上传到Facebook:
[parameters setValue:videoData forKey:@"source"];
[parameters setValue:thumbData forKey:@"thumb"];
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me/videos"
parameters:parameters
HTTPMethod:@"POST"]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if ([error.userInfo[FBSDKGraphRequestErrorGraphErrorCode] isEqual:@200]) {
NSLog(@"permission error");
}
}];
但是我收到了这个错误:
抱歉,您选择的视频文件采用我们不支持的格式。
答案 0 :(得分:4)
[parameters setValue:videoData forKey:@"source"];
必须是:
[parameters setValue:videoData forKey:@"video.mp4"];
我讨厌Facebook docs ==!。
答案 1 :(得分:1)
看看
查看支持的视频类型列表:
3g2,3gp,3gpp,asf,avi,dat,divx,dv,f4v,flv,m2ts,m4v,mkv,mod,mov,mp4,mpe,mpeg,mpeg4,mpg,mts,nsv,ogm,ogv ,qt,tod,ts,vob,wmv
Ergo,检查视频是否真的 MP4视频...