从cmformatDescription获取帧速率
我正在尝试根据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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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 itsflags
field set to zero.This means it is invalid.
CMFormatDescription
s describe several media types, andframeDuration
is not a video property. An invalidCMTime
result isCMFormatDescription
's way of saying "not found". I guess thetimescale
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 calledCMTimeCodeFormatDescriptionGetFrameDuration()
. Frame duration is aTimeCode
property (whatever that is). Mixing up your format description media types does not result in compiler errors in either language.