6

由于 mp4 是一种容器文件格式,它可以存储音频和视频文件。我正在努力寻找的是它真正的媒体类型。(无论是音频还是视频)这可以在 IOS 中完成(目标 c)吗?

4

3 回答 3

10
AVAsset *asset = [AVAsset assetWithURL:<URL to mp4>];
BOOL hasVideo = [asset tracksWithMediaType:AVMediaTypeVideo].count > 0;
BOOL hasAudio = [asset tracksWithMediaType:AVMediaTypeAudio].count > 0;
于 2013-10-29T09:57:35.617 回答
0
    BOOL isMP4VideoType; //Global Variables;
    BOOL isMP4AudioType; //Global Variables;

    //Create an object of AVAsset  class With MP4 URL.
    AVAsset *asset = [AVAsset assetWithURL:YOUR_MP4_URL];

    NSArray *aryVideoTracks = [asset tracksWithMediaType:AVMediaTypeVideo];
    NSArray *aryAudioTracks = [asset tracksWithMediaType:AVMediaTypeAudio];
    if([aryVideoTracks count]!=0)
    {
     isMP4VideoType = YES;
    }else if([aryVideoTracks count]!=0)
    {
     isMP4AudioType = YES;
    }
于 2013-10-29T10:22:15.490 回答
0
AVURLAsset* asset = [[AVURLAsset alloc]initWithURL:_assetUrl options:nil];
NSArray *audioTracks = [asset tracksWithMediaType:AVMediaTypeAudio];
AVAssetTrack * audioTrack = [audioTracks firstObject];
if([track hasMediaCharacteristic:AVMediaCharacteristicAudible]){

}
于 2017-12-26T06:19:47.903 回答