1

I have created a camera using AVFoundation, now i want my video back so i can upload it on my server how can i do that ?

I am using MKNetworkKit for upload video on server.

I am getting output like this:

file://localhost/private/var/mobile/Applications/4B2E02E5-3EE2-493E-8ECF-4B1DA29B9387/tmp/output.mov
4

1 に答える 1

1

みんな、私はここでいくつかの助けを借りてそれを理解しました。それはそのためのコードです。

- (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];
    }
}
于 2012-11-02T08:37:43.250 に答える