【问题标题】:AVAsset dimensions : track's naturalSize is not the size off the exported videoAVAsset 尺寸:轨道的 naturalSize 不是导出视频的大小
【发布时间】:2017-12-21 16:41:03
【问题描述】:

我正在使用 AVFoundation,从用户的库中导入视频。

我需要真实视频的尺寸。在我的 iPhone 7 上进行屏幕录制后,视频大小应为 (750.0, 1334.0)。 使用 AVAsset 轨道的 naturalSize 时,我总是得到 (720.0, 1280.0)

如何获得真实视频维度?

这是我正在使用的代码:

guard let track = tracks(withMediaType: AVMediaType.video).first else { return .zero }
return track.naturalSize.applying(track.preferredTransform)

【问题讨论】:

    标签: ios swift video avfoundation avasset


    【解决方案1】:

    使用 iOS 设备录制的视频将根据您在 Settings > Camera > Record Video 上设置的设置调整大小并忽略设备的屏幕分辨率。

    【讨论】:

    • 谢谢布鲁诺!但是,您如何解释如果我通过 AirDrop 将屏幕录制共享到我的 Mac,视频尺寸为 (750.0, 1334.0)?
    • 这就是iOS如何导出要通过AirDrop发送的视频的方式,即使文件的扩展名从.mov变为.mp4。您可以使用 CGAffineTransform 更改它,正如 Apples 所说的 here, The value of this property is often, but not always, identity.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多