Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine whether mp4 is a audio or video in objective C

Since mp4 is a container file format it can store audio as well as video files. What i am struggling to find out is its true media type. (Whether its a audio or video) Could this be done in IOS (objective c) ?

like image 405
Lrenger semigo Avatar asked Oct 29 '13 09:10

Lrenger semigo


1 Answers

AVAsset *asset = [AVAsset assetWithURL:<URL to mp4>];
BOOL hasVideo = [asset tracksWithMediaType:AVMediaTypeVideo].count > 0;
BOOL hasAudio = [asset tracksWithMediaType:AVMediaTypeAudio].count > 0;
like image 84
imihaly Avatar answered Sep 29 '22 01:09

imihaly