How to check Resolution, bitrate of video in iOS

后端 未结 3 1408
说谎
说谎 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:28

    Here is Avt's answer updated and tested for Swift 3:

    func resolutionForLocalVideo(url:URL) -> CGSize?
    {
      guard let track = AVURLAsset(url: url).tracks(withMediaType: AVMediaTypeVideo).first else { return nil }
      let size = track.naturalSize.applying(track.preferredTransform)
      return CGSize(width: fabs(size.width), height: fabs(size.height))
    }
    

提交回复
热议问题