Vì không có cách nào để tránh nén bằng UIImagePickerController, tôi muốn bao gồm một số ý tưởng về cách bạn có thể tạo bộ chọn hình ảnh của riêng mình để tránh nén.
này sẽ cho phép truy cập vào các tập tin video thô:
iOS 8
PHFetchResult *assetsFetchResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeVideo options:nil];
for (PHAsset *asset in assetsFetchResult) {
PHVideoRequestOptions *videoRequestOptions = [[PHVideoRequestOptions alloc] init];
videoRequestOptions.version = PHVideoRequestOptionsVersionOriginal;
[[PHImageManager defaultManager] requestAVAssetForVideo:asset options:videoRequestOptions resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) {
// the AVAsset object represents the original video file
}];
}
Nhìn vào tài liệu PhotoKit để truy cập vào bộ sưu tập (khoảnh khắc) và các tùy chọn khác.
Đây là một ứng dụng mẫu từ Apple sử dụng PhotoKit có thể được sửa đổi để trở thành một chọn ảnh: https://developer.apple.com/library/ios/samplecode/UsingPhotosFramework/Introduction/Intro.html
Đây là một thư viện chọn ảnh trên GitHub có sử dụng PhotoKit trông đầy hứa hẹn vì nó cung cấp cho bạn các đối tượng PHAsset cho tất cả các hình ảnh/video được chọn: https://github.com/guillermomuntaner/GMImagePicker
iOS 7 và dưới
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group) {
// If you want, you can filter just pictures or videos
// I just need videos so I do this:
[group setAssetsFilter:[ALAssetsFilter allVideos]];
[group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop){
if (asset){
// You can now add this ALAsset in your own video picker.
// Note that you can only access the ALAsset as long as
// you maintain a reference to the ALAssetsLibrary
// Or if you want to process the video, you can create an AVAsset:
NSURL *url = asset.defaultRepresentation.url;
AVAsset *videoAsset = [AVAsset assetWithURL:url];
}
}];
}
} failureBlock:^(NSError *error) {
NSLog(@"error enumerating AssetLibrary groups %@\n", error);
}];
Vẫn chưa tìm thấy một giải pháp cho việc này. Ai có ý tưởng gì không? – Avalanchis
Hãy xem các câu trả lời của tôi bên dưới.Nó không giống như các nhà phát triển có thể ảnh hưởng đến nén. – memmons
Avalanchis - điều này đã được trả lời 2 năm trước. Có thể nhận được chấp nhận không? – memmons