【发布时间】:2014-02-02 01:50:49
【问题描述】:
拍摄视频后,我使用UIImagePickerController 创建了相机。我点击了使用视频,我将此视频保存到照片库。现在我想知道这个视频的大小。我使用AlAssetLibrary 将视频保存到照片库。如何获取刚刚拍摄的视频的大小?请帮我。提前致谢。
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
NSURL *recordedVideoURL= [info objectForKey:UIImagePickerControllerMediaURL];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:recordedVideoURL]) {
[library writeVideoAtPathToSavedPhotosAlbum:recordedVideoURL
completionBlock:^(NSURL *assetURL, NSError *error){}
];
}
}
我尝试了以下代码来获取视频的大小但不起作用:
ALAssetRepresentation *rep = [alasset defaultRepresentation];
Byte *buffer = (Byte*)malloc(rep.size);
NSError *error = nil;
NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:&error];
NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];
【问题讨论】:
-
我不知道,但是当我的应用程序在使用上面的代码获取视频大小时崩溃了。
-
可能视频很大,你的应用被内存压力杀死了。
-
@RhythmicFistman:是的,我已经完成了。但是我在取消选择时卡在删除覆盖图像中。你能告诉我在 UICollectionView 中取消选择时如何删除覆盖吗?谢谢
-
这是一个话题变化,所以问一个新问题。
标签: ios iphone objective-c uiimagepickercontroller alassetslibrary