试图了解CMTime [英] Trying to understand CMTime
问题描述
我见过一些示例 of CMTime (三个单独的链接),但我仍然没有得到它。我正在使用AVCaptureSession和AVCaptureVideoDataOutput,我想设置输出的最大和最小帧速率。我的问题是我只是不理解CMTime结构。
显然CMTimeMake(value,timeScale)应该每隔1 / timeScale秒给我一个值帧,总值/ timeScale秒,或者我错了?
为什么不记录这个是什么?
如果它真的像那样工作,我怎么能让它有无限数量的帧?
如果真的很简单,我就是对不起,但还没有点击任何内容。
A CMTime
struct表示存储为有理数的时间长度(请参阅 CMTime参考)。 CMTime
有一个值
和一个时间刻度
字段,并代表时间价值/时间刻度秒
。
CMTimeMake
是返回 CMTime
结构的函数,例如:
CMTime t1 = CMTimeMake(1,10); // 1/10秒= 0.1秒
CMTime t2 = CMTimeMake(2,1); // 2秒
CMTime t3 = CMTimeMake(3,4); // 3/4秒= 0.75秒
CMTime t4 = CMTimeMake(6,8); // 6/8秒= 0.75秒
最后两个时间值 t3
和 t4
代表相同的时间价值,因此
CMTimeCompare(t3,t4)== 0
如果设置
没有区别p>
<$ p $> AVCaptureSession
的> videoMinFrameDuration connection.videoMinFrameDuration = CMTimeMake(1,20); //或
connection.videoMinFrameDuration = CMTimeMake(2,40);
在这两种情况下,帧之间的最小时间间隔设置为1/20 = 0.05秒。
I have seen some examples of CMTime (Three separate links), but I still don't get it. I'm using an AVCaptureSession with AVCaptureVideoDataOutput and I want to set the max and min frame rate of the the output. My problem is I just don't understand the CMTime struct.
Apparently CMTimeMake(value, timeScale) should give me value frames every 1/timeScale seconds for a total of value/timeScale seconds, or am I getting that wrong?
Why isn't this documented anywhere in order to explain what this does?
If it does truly work like that, how would I get it to have an indefinite number of frames?
If its really simple, I'm sorry, but nothing has clicked just yet.
A CMTime
struct represents a length of time that is stored as rational number (see CMTime Reference). CMTime
has a value
and a timescale
field, and represents the time value/timescale seconds
.
CMTimeMake
is a function that returns a CMTime
structure, for example:
CMTime t1 = CMTimeMake(1, 10); // 1/10 second = 0.1 second
CMTime t2 = CMTimeMake(2, 1); // 2 seconds
CMTime t3 = CMTimeMake(3, 4); // 3/4 second = 0.75 second
CMTime t4 = CMTimeMake(6, 8); // 6/8 second = 0.75 second
The last two time values t3
and t4
represent the same time value, therefore
CMTimeCompare(t3, t4) == 0
If you set the videoMinFrameDuration
of a AVCaptureSession
is does not make a difference if you set
connection.videoMinFrameDuration = CMTimeMake(1, 20); // or
connection.videoMinFrameDuration = CMTimeMake(2, 40);
In both cases the minimum time interval between frames is set to 1/20 = 0.05 seconds.
这篇关于试图了解CMTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!