【问题标题】:AV Foundation Framework video quality checkingAV Foundation Framework 视频质量检查
【发布时间】:2016-05-10 05:42:52
【问题描述】:

我做了什么:- 我在swift中使用AV Foundation Framework做了一个项目相机视频录制应用程序..

我已经完成,直到录制和保存视频

在我拍摄了视频之后我想在保存视频之前检查质量。

我正在使用 AVplayer 播放录制的视频

或

告诉我如何在使用 swift 录制视频后获得视频分辨率..

如果我得到了这意味着我会检查我的视频质量取决于分辨率

请指导我这样做..

【问题讨论】:

  • 你尝试过的东西。邮政编码。

标签: ios swift avfoundation avplayer


【解决方案1】:

既然您提到您正在使用 AVFoundation 并进行录制,我假设您确实有一个 AVAsset 的实例(或者您有一个指向文件位置的 NSURL),那么您可以在AVAsset 然后有视频大小。

https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAssetTrack_Class/index.html#//apple_ref/occ/instp/AVAssetTrack/naturalSize

// if you have the NSURL pointing to the file, you can build an AVAsset by this
let asset: AVAsset = AVURLAsset(URL: fileURL)

// get the first track
if let track = asset.tracksWithMediaType(AVMediaTypeVideo)?.first {

  let size: CGSize = track.naturalSize

  // then you can have the width and height
  let width = size.width
  let height = size.height
}

附带说明,除了视频的分辨率之外,还有其他因素,例如视频的比特率,也会影响质量。更多内容可在苹果文档中找到。

https://developer.apple.com/library/ios/documentation/CoreMedia/Reference/CMFormatDescription/index.html#//apple_ref/c/tdef/CMVideoFormatDescriptionRef

【讨论】:

  • 你好。感谢您的回答。你知道为什么这个网址https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_adv_example_hevc/master.m3u8 总是得到nil吗?我还检查了所有其他媒体类型(audio、metadata 等),但结果相同 - nil。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-23
  • 2011-02-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-29
  • 1970-01-01
相关资源
最近更新 更多