5

I am attempting to load a file called output.mov (created on the iPhone) as an AVURLAsset using the following code:

NSURL *outputURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), @"output.mov"]];

AVURLAsset *videoAsset = [AVURLAsset URLAssetWithURL:outputURL options:nil];

The file is located in the tmp directory of the app. No errors appear, but it seems that the asset is not loaded as no metadata is available (i.e. calling NSLog(@"%@", [videoAsset commonMetadata]) returns nothing) so I can't do anything with the asset.

I have used the following code to ensure that the resource is reachable via the URL, and it definitely seems to be:

if ([outputURL checkResourceIsReachableAndReturnError:&err] == NO)
        NSLog(@"Not reachable!");

so I am unsure why the asset is not loading. I have also tried loading the asset using [AVAsset assetWithURL:] but that also doesn't work.

Any help would be greatly appreciated.

4

1 回答 1

0

这可能是因为您的文件的编码。例如,如果该文件是使用Sorenson 3 (SVQ3)编解码器编码的,则您需要在将媒体文件传递给AVURLAsset. 你可以使用QTMovieModernizer类来做到这一点。

于 2020-02-06T18:09:07.033 回答