ALAssetsLibrary에서 모든 비디오 자산을 가져옵니다 (기본적으로 기본 카메라 응용 프로그램에서 기록되는 모든 항목).ALAsset URL에서 생성 된 AVAsset에는 트랙이나 재생 시간이 없습니다.
// The end of the enumeration is signaled by asset == nil.
if (alAsset) {
//Get the URL location of the video
ALAssetRepresentation *representation = [alAsset defaultRepresentation];
NSURL *url = [representation url];
//Create an AVAsset from the given URL
NSDictionary *asset_options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
AVAsset *avAsset = [[AVURLAsset alloc] initWithURL:url options:asset_options];//[AVURLAsset URLAssetWithURL:url options:asset_options];
//Here is the problem
NSLog([NSString stringWithFormat:@"%i", [avAsset.tracks count]]);
NSLog([NSString stringWithFormat:@"%f", CMTimeGetSeconds(avAsset.duration)]);
}
NSLog가 내 ALAsset에서 입수 한 AVAsset 0 트랙을 가지고보고, 0.0 초의 시간이있다 : I는 각 비디오에이 작업을 수행 각 비디오 자산에 열거를 실행하고 있습니다. URL을 확인한 결과 올바른 것으로 보이는 것이 "assets-library : //asset/asset.MOV? id = 9F482CF8-B4F6-40C2-A687-0D05F5F25529 & ext = MOV"입니다. alAsset은 실제로 비디오이고 정확한 비디오입니다. 왜냐하면 alAsset.thumbnail을 표시했기 때문에 비디오의 정확한 미리보기가 표시 되었기 때문입니다.
이 모든 것들이 avAsset의 초기화 과정에서 잘못된 부분이 있다고 생각하게 만듭니다.하지만 내 인생에서 무엇이 잘못 될지 알 수 없습니다. 누구든지 나를 도울 수 있습니까?
업데이트 :
내가 URL을 ALAssetRepresentation 나에게 주어지고 있음을 확인했습니다 생각은 나에게 정확한 미리보기를 제공하기 때문에 이상한 인 결함이 있습니다.
0
Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)" UserInfo=0x19df60 {}
난 아직도 그 원인이 무엇인지 확실하지 않다 : 그것은이 나에게주는
NSLog([NSString stringWithFormat:@"%i", [url checkResourceIsReachableAndReturnError:&error]]);
NSLog([NSString stringWithFormat:@"%@", error]);
: 나는이 코드를 추가했다. 내가 알아 채는 유일한 점은 "assets-library : //asset/asset.MOV? id = 9F482CF8-B4F6-40C2-A687-0D05F5F25529 & ext = MOV"라는 URL이 내가 본 것과 다르다는 것입니다. 내가 이것을 주변에서 찾고 있었던 것에 따라. 다른 곳에서 본 적이있는 파일은 "assets-library : //asset/asset.MOV? id = 1000000394 & ext = MOV"와 유사하며 영숫자, 대시로 구분 된 이름 대신 숫자가 사용됩니다.
도움이된다면 XCode 4.2 Beta 및 iOS5를 사용하고 있습니다. 당신이 무엇이든 생각할 수 있으면 저에게 알려주십시오. 감사.
iOS 7에서는 괜찮습니까? ios7에서 문제가 발생했습니다. –