从cmformatDescription获取帧速率

发布于 2025-02-11 02:12:55 字数 719 浏览 0 评论 0原文

我正在尝试根据cmformatDescription计算视频格式的帧速率,但是我得到了奇怪的输出,我不知道该怎么办。根据文档,“值/时间表=秒”。这也是此问题中的答案。

从FaceTime摄像机获取视频流时正在调用代码:

let av = device.activeFormat
let fd = av.formatDescription
print("time scale",fd.frameDuration.timescale)
print("value",fd.frameDuration.value)  
print("value/timescale=",fd.frameDuration.value)/Int64(fd.frameDuration.timescale))

这是输出:

时间尺度480
值2749654773878
Value/TimesCale = 5728444445.579166

我缺少什么?什么是帧速率?

编辑 :看来有一个错误,或者也许有些错误。时间尺度始终==高度(格式描述)。我使用USB摄像头尝试了一下,它们总是相等的。

I am trying to calculate frame rate of a video format based on CMFormatDescription but I'm getting strange output that I do not know what to do with. According to the documentation, "value/timescale = seconds". This is also the answer in this question.

The code is being called while getting a video stream from FaceTime camera:

let av = device.activeFormat
let fd = av.formatDescription
print("time scale",fd.frameDuration.timescale)
print("value",fd.frameDuration.value)  
print("value/timescale=",fd.frameDuration.value)/Int64(fd.frameDuration.timescale))

This is the output:

time scale 480
value 2749654773878
value/timescale= 5728447445.579166

What am I missing? What is the frames rate?

EDIT: It seems that there is a bug or perhaps something is terribly wrong. time scale is always == height (of the format description). I tried it with a usb camera and they are always equal.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生来就爱笑 2025-02-18 02:12:55

tl; dr 您不查询设备的帧速率,但是您可以选择您想要的帧速率

cmtime您收到的值的flags five设置为零。
这意味着它无效。

cmformatDescription s描述几种媒体类型,frameAmeuration不是视频属性。无效的cmtime结果是cmformatDescription说“找不到”的方式。我猜timeScale是格式的高度只是不确定的行为&我敢打赌,它在英特尔Mac上是不同的。

在普通的旧C中更容易看到此问题,其中swift frameAmenation属性被称为cmtimecodeformatdescriptiongetgetFramedUrameation()。框架持续时间为timecode属性(无论是什么)。混合格式说明媒体类型不会导致两种语言中的编译器错误。

TL;DR You don't query a device's frame rate, but you can choose the frame rate you want

The CMTime value you're receiving has its flags field set to zero.
This means it is invalid.

CMFormatDescriptions describe several media types, and frameDuration is not a video property. An invalid CMTime result is CMFormatDescription's way of saying "not found". I guess the timescale being the format's height is just Undefined Behaviour & I'll bet it's different on an intel mac.

This problem is easier to see in plain old C, where the sugared swift frameDuration property is called CMTimeCodeFormatDescriptionGetFrameDuration(). Frame duration is a TimeCode property (whatever that is). Mixing up your format description media types does not result in compiler errors in either language.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文