Questions tagged [cmtime]

CMTime structs are non-opaque mutable structs representing times (either timestamps or durations). A CMTime is represented as a rational number, with a numerator (an int64_t value), and a denominator (an int32_t timescale). A flags field allows various non-numeric values to be stored (+infinity, -infinity, indefinite, invalid). There is also a flag to mark whether or not the time is completely precise, or had to be rounded at some point in its past.

CMTime structs are non-opaque mutable structs representing times (either timestamps or durations).

A CMTime is represented as a rational number, with a numerator (an int64_t value), and a denominator (an int32_t timescale). A flags field allows various non-numeric values to be stored (+infinity, -infinity, indefinite, invalid). There is also a flag to mark whether or not the time is completely precise, or had to be rounded at some point in its past.

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.

Click here for Apple Documentaion of CMTime class.

98 questions
0
votes
2 answers

Converting CMTime values to swift

I have the following 2 lines of code that I am moving to Swift but I am a little stuck. CMTime trimmingTime = CMTimeMake(lround(videoAsset.naturalTimeScale / videoAsset.nominalFrameRate), videoAsset.naturalTimeScale); CMTimeRange timeRange =…
ORStudios
  • 3,157
  • 9
  • 41
  • 69
0
votes
1 answer

How to pass Float in CMTimeMake's timescale Int32

I am working on CMTimeMake in order to add slow and fast motion effect to Video. Where we have to divide by Video scale for Fast effect and multiply by Video scale for Slow effect. Here it is: let videoScaleFactor = Int64(2) // Get the scaled…
user2786
  • 656
  • 4
  • 13
  • 35
0
votes
2 answers

What kinds of CMTime are invalid?

kCMTimeInvalid is invalid CMTime, but based on Apple document, there are more invalid CMTime, what are they? What does CMTime "invalid" means? It's overflow, uninitiated or anything…
allenlinli
  • 2,066
  • 3
  • 27
  • 49
0
votes
1 answer

Trying to store CMTime as Transformable property on Core Data

I have used transformable properties of Core Data before but not with C objects like CMTime. I need to store a CMTime on Core Data using transformable. On the Model object I have declared this as transformable. @property (nonatomic, retain) id…
Duck
  • 34,902
  • 47
  • 248
  • 470
0
votes
1 answer

Error archiving CMTime with NSKeyedArchiver in swift4.0 in ios9.3

The following code archivedTimes() builds successfully in swift4. And it runs fine on a device with ios10.3 installed. typealias Time = CMTime typealias Times = [Time] static let times: Times = Array.init(1...9).map({ CMTime.init(value: $0,…
SirEnder
  • 564
  • 4
  • 14
0
votes
1 answer

Cant convert Swift CMTimeRange to Float or get the number?

Im having a data type issue - with AVPlayer in Swift I am given a CMTimeRange when I try to get: AudioPlayerManager.shared.currentTrack?.playerItem?.loadedTimeRanges[0] What is printed with this is: Optional(CMTimeRange: {{0/1 = 0.000},…
blue
  • 7,175
  • 16
  • 81
  • 179
0
votes
1 answer

Playing AVPlayerItem CurrentTime in Seconds Return Inconsistent Values

I am retooling my audio player application to use AVQueuePlayer instead of AVAudioPlayer, as I now appreciate that I need to be able to queue up audio files for playback. Since AVQueuePlayer is a subclass of AVPlayer, which uses CMTime to keep track…
Gthoma2
  • 687
  • 1
  • 9
  • 22
0
votes
0 answers

Get valid Float value to use in AVPlayer from CMTime

Im trying to set a slider to the current value of an audio file which is playing. But I'm getting problems when setting the values for the slider. when i use a timer from ViewDidLoad: self.timer = Timer.scheduledTimer(timeInterval: 0.1, target:…
Pippo
  • 1,439
  • 1
  • 18
  • 35
0
votes
1 answer

CMTIME_COMPARE_INLINE in Swift 3?

Want to compare CMTime and based on that I am performing loop. Converting ObjectiveC to Swift, I can't found suitable method for CMTIME_COMPARE_INLINE. CMTime oneSecond = CMTimeMake( 1, 1 ); CMTime oneSecondAgo = CMTimeSubtract( timestamp, oneSecond…
Sohil R. Memon
  • 9,404
  • 1
  • 31
  • 57
0
votes
1 answer

AVAssetExportSession only works first 6 times

Updated code sample, console output and information I'm trying to get the total duration of a video composition, divide it by 10, round up, then loop through and splice the video composition at those intervals. It works, but after the…
0
votes
1 answer

Export video with custom CMTimeRange issue

I guess i'm missing something. I have a slider which changes the asset duration, and the start time as well. If i'm exporting the video with the full duration, as let timeRange = originalVideoTrack.timeRange do { try…
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
0
votes
1 answer

iOS AVFoundation how to convert camera frames per second to create a timelapse using CMTime?

I have an iPhone camera attachment that captures video at 9FPS and makes it available as individual UIImages. I'm trying to stitch these images together to create a timelapse video of what the camera sees using AVFoundation. I'm not sure how to…
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
0
votes
2 answers

AVPlayer SeekToTime not working. Starting from beginning everytime

I'm having trouble with UISlider and AVPlayer scrubbing method. Every time the method is invoked the player restarts from 0. I tried debugging and seems that the slider value is right but when I Step Over, it's set 0, thus the player restarts. This…
0
votes
1 answer

CMTimeClampToRange() doesn't seem to return a CMTime that's inside the given range

I have the following code in my project: CMTimeRange clipRange = clip.range; CMTime clipTime = CMTimeClampToRange(editor.currentClipTime, clipRange); According to the documentation, CMTimeClampToRange() should behave like: For a given CMTime and…
Ja͢ck
  • 170,779
  • 38
  • 263
  • 309
0
votes
1 answer

export UIImage array to video - setting CMTime accordingly

I have an UIImage array of 10 frames. I want to export this as a movie of 15 seconds in total. so it would have to loop those 10 frames for as long as 15 seconds. between each frame I'd need an interval of 0.2 seconds. I have managed to create a…
Ramin Afshar
  • 989
  • 2
  • 18
  • 34