来自摄像机video的数据返回零

这是我从UIImagePickerController获取video的代码:

 - (IBAction)takeVideo:(UIButton *)sender { UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.allowsEditing = YES; picker.sourceType = UIImagePickerControllerSourceTypeCamera; picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil]; [self presentViewController:picker animated:YES completion:NULL]; } - (void)viewDidAppear:(BOOL)animated { self.movieController = [[MPMoviePlayerController alloc] init]; self.movieController.controlStyle = MPMovieControlStyleNone; [self.movieController setContentURL:self.movieURL]; [self.movieController.view setFrame:CGRectMake (15, 125, 292, 390)]; self.movieController.view.backgroundColor = [UIColor clearColor]; [self.view addSubview:self.movieController.view]; [self.movieController play]; NSString *myString = [self.movieURL absoluteString]; NSData *videoData = [NSData dataWithContentsOfFile:myString]; NSLog(@"%@",[NSByteCountFormatter stringFromByteCount:videoData.length countStyle:NSByteCountFormatterCountStyleFile]); [self setImageDataToSend:videoData]; } 

哪里:

 NSString *myString = [self.movieURL absoluteString]; NSData *videoData = [NSData dataWithContentsOfFile:myString]; NSLog(@"%@",[NSByteCountFormatter stringFromByteCount:videoData.length countStyle:NSByteCountFormatterCountStyleFile]); [self setImageDataToSend:videoData]; 

返回零? 显而易见的是如何显示数据?

获得像这样的大小

 NSError *error = nil; NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[self.movieURL path] error:&error]; if (!error) { NSLog(@" size= %@",[attributes objectForKey:NSFileSize]); }else{ NSLog(@"err= %@",error); } 

如果你想KB

 NSString *myString = [self.movieURL path]; NSData *videoData = [NSData dataWithContentsOfFile:myString]; NSLog(@"%@",[NSByteCountFormatter stringFromByteCount:videoData.length countStyle:NSByteCountFormatterCountStyleFile]);