我已经使用 AVFoundation 创建了一个相机,现在我想要我的视频,以便我可以将它上传到我的服务器上,我该怎么做?
我正在使用 MKNetworkKit 在服务器上上传视频。
我得到这样的输出:
file://localhost/private/var/mobile/Applications/4B2E02E5-3EE2-493E-8ECF-4B1DA29B9387/tmp/output.mov
我已经使用 AVFoundation 创建了一个相机,现在我想要我的视频,以便我可以将它上传到我的服务器上,我该怎么做?
我正在使用 MKNetworkKit 在服务器上上传视频。
我得到这样的输出:
file://localhost/private/var/mobile/Applications/4B2E02E5-3EE2-493E-8ECF-4B1DA29B9387/tmp/output.mov
伙计们,我通过一些帮助弄清楚了这里是代码。
- (void) captureOutput:(AVCaptureFileOutput *)captureOutput
didFinishRecordingToOutputFileAtURL:(NSURL *)anOutputFileURL
fromConnections:(NSArray *)connections
error:(NSError *)error
{
videodata = [NSData dataWithContentsOfURL:outputFileURL];
//NSLog(@"output file url is :%@",anOutputFileURL);
NSLog(@"output video data size is:%d", videodata.length);
if ([[self delegate] respondsToSelector:@selector(recorder:recordingDidFinishToOutputFileURL:error:)]) {
[[self delegate] recorder:self recordingDidFinishToOutputFileURL:anOutputFileURL error:error];
}
//NSLog(@"captureOutput is: %@",captureOutput);
// NSLog(@"anOutputFileURL is: %@",anOutputFileURL);
//videoPath = [NSString stringWithContentsOfURL:anOutputFileURL encoding:NSUTF8StringEncoding error:nil];
//videoPath = [anOutputFileURL absoluteString];
//videoURL = anOutputFileURL;
// videodata = captureOutput;
// NSLog(@"video path is: %@",videodata);
UIAlertView *message = [[UIAlertView alloc] initWithTitle:nil
message:@"Do you want to upload this content to the yes stream network ?"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Yes",@"No",nil];
[message show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Yes"])
{
NSLog(@"Yes was selected.");
self.flUploadEngine = [[fileUploadEngine alloc] initWithHostName:@"manektech.net" customHeaderFields:nil];
NSMutableDictionary *postParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"testApp", @"appID",
nil];
self.flOperation = [self.flUploadEngine postDataToServer:postParams path:@"/dilipvideotest/savefile.php"];
[self.flOperation addData:videodata forKey:@"uploadfile" mimeType:@"video/mov" fileName:@"output.mov" ];
[self.flOperation onCompletion:^(MKNetworkOperation *operation) {
NSLog(@"response string is : %@", [operation responseString]);
/*
This is where you handle a successful 200 response
*/
}
onError:^(NSError *error) {
NSLog(@"error : %@", error);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
}];
[self.flUploadEngine enqueueOperation:self.flOperation ];
}
else if([title isEqualToString:@"No"])
{
NSLog(@"No was selected.");
//[self readMovie:outputFileURL];
}
}