Note that there are some explanatory texts on larger screens.

plurals
  1. POAVAsset has no tracks or duration when created from an ALAsset URL
    primarykey
    data
    text
    <p>I'm pulling all of the video assets from ALAssetsLibrary (Basically everything that's being recorded from the native camera app). I am then running an enumeration on each video asset that does this to each video:</p> <pre><code> // 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)]); } </code></pre> <p>NSLog is reporting that the AVAsset that I've gotten from my ALAsset has 0 tracks, and has a duration of 0.0 seconds. I checked the url, and it's "assets-library://asset/asset.MOV?id=9F482CF8-B4F6-40C2-A687-0D05F5F25529&amp;ext=MOV" which seems correct. I know alAsset is actually a video, and the correct video, because I've displayed alAsset.thumbnail, and it's shown the correct thumbnail for the video.</p> <p>All this leads me to believe there's something going wrong in the initialization for avAsset, but for the life of me, I can't figure out what's going wrong. Can anyone help me?</p> <p><strong>Update:</strong></p> <p>I think i've confirmed that the url being given to me by ALAssetRepresentation is faulty, which is weird because it gives me the correct thumbnail. I added this code in:</p> <pre><code>NSLog([NSString stringWithFormat:@"%i", [url checkResourceIsReachableAndReturnError:&amp;error]]); NSLog([NSString stringWithFormat:@"%@", error]); </code></pre> <p>It gives me this:</p> <pre><code>0 Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)" UserInfo=0x19df60 {} </code></pre> <p>I'm still not sure what would cause that. The only thing I'm noticing is the url, which is "assets-library://asset/asset.MOV?id=9F482CF8-B4F6-40C2-A687-0D05F5F25529&amp;ext=MOV" is different from what I've seen as I've been searching around for this. The one i've seen elsewhere looks more like "assets-library://asset/asset.MOV?id=1000000394&amp;ext=MOV", with a number instead of an alphanumeric, dash separated name. </p> <p>If it helps, I'm using XCode 4.2 Beta, and iOS5. Please let me know if you can think of anything. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload