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
1 answer

Float64 in Core Data?

I'm using CMTime for AVAssets for video clip. To trim the video without saving the new video file I just want to keep track of the start time and the duration. The CMTimeGetSeconds() method will return a Float64, what would be the best way to store…
Erik
  • 5,791
  • 5
  • 30
  • 45
0
votes
0 answers

How to use AVMutableComposition to create a video sequence / play one video after another?

I have a bunch of videos that I just want to play one after the other. I made sure that my AVAssets are fine, and tried to create a sequence using the following function: func makeSequence(from assets: [AVURLAsset], to previewComposition:…
0
votes
1 answer

Fix "Type 'CMTime' has no member 'zero'" error in Xcode, for 16.2?

It seems that currently (14.2 (14C18)) if you use CMTime.zero self.player?.seek(to: .zero, toleranceBefore: .zero, toleranceAfter: .zero) or self.player?.seek(to: .zero) you'll see the error However, the project does compile and run…
Fattie
  • 27,874
  • 70
  • 431
  • 719
0
votes
0 answers

Understanding the role of time in a AVCaptureSession regarding CMSampleBuffers

I recently started programming in Swift as I am trying to work out an iOS camera app idea I've had. The main goal of the project is to save the prior 10 seconds of video before the record button is tapped. So the app is actually always capturing and…
0
votes
0 answers

play video from particular time stamp in h264 frames in swift

I’m playing h.264 frames from file, now I want add custom controls to it, added the slider and slider moving as per video but when I seek (backward/forward) the slider position I want to play from updated timestamp
Raj
  • 1
0
votes
0 answers

How to match RPScreenRecorder screenshot times to application logs

I'm trying to align the screenshots emitted by RPScreenRecorder's startCapture method to logs saved elsewhere in my code. I was hoping that I could just match CMSampleBuffer's presentationTimeStamp to the timestamp reported by…
ryanipete
  • 419
  • 5
  • 15
0
votes
1 answer

iOS how can I get CMTime from Int64 that create by Date().timeIntervalSince1970

As same as the title I am get a Timestamp by Date().timeIntervalSince1970 how can I transform it to CMTime?
normidar
  • 445
  • 5
  • 11
0
votes
2 answers

Im trying to update a UISlider with the current time from a AVPlayer

I'm trying to update a UISlider with the current time from a AVPlayer. Im using a NSTimer to call a method with this code every 1 second: CMTime duration = audioPlayer.currentTime; float seconds = CMTimeGetSeconds(duration); …
Sam Baumgarten
  • 2,231
  • 3
  • 21
  • 46
0
votes
1 answer

Swift: Need Help for CMTimeRange(start: end:)

I have a problem with CMTimeRange. Warning occurs when attempting to set CMTimeRange. The CMTimes that will enter the parameters of CMTimeRange are fine (as shown in the screenshot). Is there a problem with this code? The bottom line is the warning…
0
votes
0 answers

Exporting image sequence from video in swift

I have the below code to export a video (60fps) to an image sequence. However, despite loads of stackoverflow examples, I seem to not master properly the CMTime, as images 1-30 are the same, then 31-90 are the same, then 91-130, 131-150... like if…
Laurent Crivello
  • 3,809
  • 6
  • 45
  • 89
0
votes
1 answer

Modern way of CMTime and CMTimeRange in plist using Swift

What are the most 'modern' Swift ways to store objects like CMTime and CMTimeRange in plist? I have tried the following approaches. The dictionary object gets stored in plist. dictionary["timeRange"] = NSValue(timeRange: timeRange) and also, …
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
0
votes
0 answers

Is there a function to get 10 frames per second of video?

I am trying to get 10 frames per second of video from imagePickerController. I use this function, but images from 0.1s -> 1s are the same, from 1.1 to 2s too. Is there anyway to do? This is my function: func imagePickerController(_ picker:…
Tuan Ho Si
  • 25
  • 5
0
votes
1 answer

Looping AVPlayer with custom Start/End Times

I am using an AVPlayer to play video. I would like to be able to loop sections of the video based on the user's input (while the video is playing, the user can press a button to start a loop and then press it once more to end after a few seconds…
spitchay
  • 89
  • 1
  • 10
0
votes
1 answer

How can I set offset of a video in Swift 4 ? Seek(to:) doesn't seem to work

I am having an issue setting offset of AVQueuePlayer video. I have tried seek(to function to set offset of the video but it doesn't seem to work. The video always starts from 0 Seconds. Other requirements are playing it with control and looping back…
Arsalan Haider
  • 559
  • 3
  • 9
  • 23
0
votes
2 answers

How can I access the length of the video that is CURRENTLY being recorded

I have an iOS camera app where when the user starts to hold a button I want to start recording and within that longTap method be able to know how long the recording is CURRENTLY... BEFORE it has ended. I want to know how long the video is as of now…
user10813210