How to check Resolution, bitrate of video in iOS

后端 未结 3 1415
说谎
说谎 2021-02-07 15:24

I\'m developing a video compression functionally; my ideas are below:

  1. Getting resolution and bit-rate of video.
  2. Check resolution of video. If it larger 6
3条回答
  •  故里飘歌
    2021-02-07 15:38

    Video resolution in Swift:

    func resolutionForLocalVideo(url:NSURL) -> CGSize?
    {
        guard let track = AVAsset(URL: url).tracksWithMediaType(AVMediaTypeVideo).first else { return nil }
        let size = CGSizeApplyAffineTransform(track.naturalSize, track.preferredTransform)
        return CGSize(width: fabs(size.width), height: fabs(size.height))
    }
    

    Solutions without preferredTransform do not return correct values for some videos on the latest devices!

提交回复
热议问题