由于mp4是容器文件格式,因此它可以存储音频和视频文件。我正在努力寻找的是它真正的媒体类型。 (无论是音频还是视频)这可以在IOS(目标c)中完成吗?
答案 0 :(得分:9)
AVAsset *asset = [AVAsset assetWithURL:<URL to mp4>];
BOOL hasVideo = [asset tracksWithMediaType:AVMediaTypeVideo].count > 0;
BOOL hasAudio = [asset tracksWithMediaType:AVMediaTypeAudio].count > 0;
答案 1 :(得分: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;
}
答案 2 :(得分:0)
AVURLAsset* asset = [[AVURLAsset alloc]initWithURL:_assetUrl options:nil];
NSArray *audioTracks = [asset tracksWithMediaType:AVMediaTypeAudio];
AVAssetTrack * audioTrack = [audioTracks firstObject];
if([track hasMediaCharacteristic:AVMediaCharacteristicAudible]){ }