Platforms to show: All Mac Windows Linux Cross-Platform
CMTimeMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | AVFoundation | MBS AVFoundation Plugin | 13.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
A CMTime is represented as a rational number, with a numerator (an int64 value), and a denominator (an int32 timescale). Conceptually, the timescale specifies the fraction of a second each unit in the numerator occupies. Thus if the timescale is 4, each unit represents a quarter of a second; if the timescale is 10, each unit represents a tenth of a second, and so on. In addition to a simple time value, a CMTime can represent non-numeric values: +infinity, -infinity, and indefinite. Using a flag CMTime indicates whether the time been rounded at some point.
CMTimes contain an epoch number, which is usually set to 0, but can be used to distinguish unrelated timelines: for example, it could be incremented each time through a presentation loop, to differentiate between time N in loop 0 from time N in loop 1.
Additional functions for managing dates and times are described in Time Utilities Reference. Note that CMTime is designed for media timelines whereas functions in Time Utilities Reference are designed for working with wall-clock time in Core Foundation framework; see also AV Foundation Constants Reference.
- 12 properties
- property Epoch as Int64
- property Flags as Integer
- property HasBeenRounded as Boolean
- property IsIndefinite as Boolean
- property IsInvalid as Boolean
- property IsNegativeInfinity as Boolean
- property IsNumeric as Boolean
- property IsPositiveInfinity as Boolean
- property IsValid as Boolean
- property Seconds as Double
- property Timescale as Integer
- property Value as Int64
- 10 methods
- method AbsoluteValue as CMTimeMBS
- method Add(other as CMTimeMBS) as CMTimeMBS
- method Compare(other as CMTimeMBS) as Integer
- method Constructor(Value as Int64, Timescale as Integer, Flags as Integer = 1, Epoch as Int64 = 0)
- method ConvertScale(newTimescale as Integer, RoundingMethod as Integer = 1) as CMTimeMBS
- method Description as string
- method Multiply(multiplier as Integer) as CMTimeMBS
- method MultiplyByFloat(multiplier as Double) as CMTimeMBS
- method Show
- method Subtract(other as CMTimeMBS) as CMTimeMBS
- 10 shared methods
- shared method kCMTimeIndefinite as CMTimeMBS
- shared method kCMTimeInvalid as CMTimeMBS
- shared method kCMTimeNegativeInfinity as CMTimeMBS
- shared method kCMTimePositiveInfinity as CMTimeMBS
- shared method kCMTimeZero as CMTimeMBS
- shared method Make(value as Int64, timescale as Integer) as CMTimeMBS
- shared method MakeWithEpoch(value as Int64, timescale as Integer, Epoch as Int64) as CMTimeMBS
- shared method MakeWithSeconds(seconds as Double, preferredTimeScale as Int32 = 600) as CMTimeMBS
- shared method Maximum(t1 as CMTimeMBS, t2 as CMTimeMBS) as CMTimeMBS
- shared method Minimum(t1 as CMTimeMBS, t2 as CMTimeMBS) as CMTimeMBS
- 14 constants
Constants
Constant | Value | Description |
---|---|---|
kCMTimeMaxTimescale | &h7fffffff | A constant to define the maximum timescale. |
Flags
Constant | Value | Description |
---|---|---|
kCMTimeFlags_HasBeenRounded | 2 |
Indicates that the time has been rounded. |
kCMTimeFlags_ImpliedValueFlagsMask | 28 |
Indicates that the time is +infinity, -infinity, or indefinite. Use this value with bitwiseAnd on the flags. |
kCMTimeFlags_Indefinite | 16 |
Indicates that the time is indefinite. |
kCMTimeFlags_NegativeInfinity | 8 |
Indicates that the time is -infinity. |
kCMTimeFlags_PositiveInfinity | 4 |
Indicates that the time is +infinity. |
kCMTimeFlags_Valid | 1 |
Indicates that the time is valid. |
Rounding Methods
Constant | Value | Description |
---|---|---|
kCMTimeRoundingMethod_Default | 1 |
Synonym for kCMTimeRoundingMethod_RoundHalfAwayFromZero. |
kCMTimeRoundingMethod_QuickTime | 4 | Use kCMTimeRoundingMethod_RoundTowardZero if converting from larger to smaller scale (that is, from more precision to less precision), but use kCMTimeRoundingMethod_RoundAwayFromZero if converting from smaller to larger scale (i.e. from less precision to more precision). more |
kCMTimeRoundingMethod_RoundAwayFromZero | 3 |
Round away from zero if abs(fraction) is > 0. |
kCMTimeRoundingMethod_RoundHalfAwayFromZero | 1 |
Round towards zero if abs(fraction) is < 0.5, away from 0 if abs(fraction) is >= 0.5. |
kCMTimeRoundingMethod_RoundTowardNegativeInfinity | 6 |
Round towards -infinity if fraction is not 0. |
kCMTimeRoundingMethod_RoundTowardPositiveInfinity | 5 |
Round towards +infinity if fraction is not 0. |
kCMTimeRoundingMethod_RoundTowardZero | 2 |
Round towards zero if fraction is not 0. |
This class has no sub classes.
Some methods using this class:
- AVCaptureFileOutputMBS.recordedDuration as CMTimeMBS
- AVMutableCompositionMBS.scaleTimeRange(timeRange as CMTimeRangeMBS, duration as CMTimeMBS)
- AVMutableCompositionTrackMBS.insertTimeRange(timeRange as CMTimeRangeMBS, AssetTrack as AVAssetTrackMBS, startTime as CMTimeMBS, byref error as NSErrorMBS) as boolean
- AVMutableMovieTrackMBS.scaleTimeRange(timeRange as CMTimeRangeMBS, duration as CMTimeMBS)
- AVPlayerItemOutputMBS.itemTimeForHostTime(hostTimeInSeconds as Double) as CMTimeMBS
- AVPlayerMBS.seekToTime(time as CMTimeMBS, fireEvent as boolean = false, tag as Variant = nil)
- AVPlayerMBS.setRate(rate as Double, time as CMTimeMBS, HostTime as CMTimeMBS)
- AVVideoCompositionLayerInstructionMBS.getCropRectangleRampForTime(time as CMTimeMBS, byref startCropRectangle as CGRectMBS, byref endCropRectangle as CGRectMBS, byref timeRange as CMTimeRangeMBS) as Boolean
- AVVideoCompositionLayerInstructionMBS.getOpacityRampForTime(time as CMTimeMBS, byref startOpacity as Double, byref endOpacity as Double, byref timeRange as CMTimeRangeMBS) as boolean
- CMTimeRangeMBS.Make(start as CMTimeMBS, duration as CMTimeMBS) as CMTimeRangeMBS
Some properties using for this class:
- AVCaptureReactionEffectStateMBS.startTime as CMTimeMBS
- AVMetadataItemMBS.duration as CMTimeMBS
- AVMutableMovieTrackMBS.preferredMediaChunkDuration as CMTimeMBS
- AVPlayerItemMBS.reversePlaybackEndTime as CMTimeMBS
- AVPlayerMBS.currentTime as CMTimeMBS
- CMTimeRangeMBS.Duration as CMTimeMBS
- AVAssetImageGeneratorMBS.requestedTimeToleranceAfter as CMTimeMBS
- AVCaptureMovieFileOutputMBS.movieFragmentInterval as CMTimeMBS
- AVMutableMetadataItemMBS.duration as CMTimeMBS
- AVMutableVideoCompositionMBS.frameDuration as CMTimeMBS
Some events using this class:
- AVFoundationMBS.generateCGImagesAsynchronouslyForTimesCompleted(generator as AVAssetImageGeneratorMBS, requestedTime as CMTimeMBS, image as Variant, actualTime as CMTimeMBS, result as Integer, error as NSErrorMBS, tag as Variant)
- AVFoundationMBS.legibleOutputDidOutputAttributedStrings(output as AVPlayerItemLegibleOutputMBS, strings() as Variant, nativeSamples() as CMSampleBufferMBS, itemTime as CMTimeMBS)
- AVFoundationMBS.PeriodicTimeObserver(Player as AVPlayerMBS, time as CMTimeMBS, tag as Variant)
- AVFoundationMBS.playerItemSeekToTimeFinished(player as AVPlayerItemMBS, time as CMTimeMBS, toleranceBefore as CMTimeMBS, toleranceAfter as CMTimeMBS, finished as boolean, tag as Variant)
- AVFoundationMBS.playerSeekToTimeFinished(player as AVPlayerMBS, time as CMTimeMBS, toleranceBefore as CMTimeMBS, toleranceAfter as CMTimeMBS, finished as boolean, tag as Variant)
Some examples using this class:
- /AVFoundation/Add text to video
- /AVFoundation/Make Video From Images
- /AVFoundation/Make Video From Images with transparency
- /AVFoundation/Merge and Crop Videos
- /AVFoundation/Merge Audio and Video
- /AVFoundation/Overlay video track with picture
- /AVFoundation/Simple Player
- /AVFoundation/Thumbnail sync
- /AVFoundation/Transcode
- /AVFoundation/Transcode parallel
Blog Entries
Xojo Developer Magazine
The items on this page are in the following plugins: MBS AVFoundation Plugin.
CMTimeMappingMBS - CMTimeRangeMBS