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

How do I determine the duration of a sample buffer uses in an AVAssetWriter

I have a sample buffer that I'm using to capture video for an AVAssetWriter. I'm trying to figure out a way to determine how much video (time) I have captured. currently I am able to access the current buffer timestamp by using CMTime pts =…
user379468
  • 3,989
  • 10
  • 50
  • 68
3
votes
0 answers

Epoch time of CMTime

Apple's AVFoundation documentation has the following for CMTime: "The epoch number of a CMTime is usually set to 0, but you can use it to distinguish unrelated timelines. For example, the epoch could be incremented each cycle through a presentation…
Boon
  • 40,656
  • 60
  • 209
  • 315
2
votes
2 answers

AVMutableAudioMix - Can't fade out

I'm trying to fade out a AVComposition track (its an audio track for a video). I can fade it up at the start no problem, but am having a lot of trouble fading it out at the end. Here is my code: AVMutableAudioMixInputParameters *audioMixParameters =…
gamblor87
  • 523
  • 1
  • 4
  • 12
2
votes
3 answers

NSValue may not respond to... warning

I'm getting a warning in XCode which says NSValue may not respond to +valueWithCMTime:' but I'm not sure what I'm doing wrong. In my header file, I have this: #import #import…
XSL
  • 2,965
  • 7
  • 38
  • 61
2
votes
3 answers

Issue with updating playback time in MPNowPlayingInfoCenter from AVPlayer player periodic time observer block

I have an issue with updating playing info. Please have a look at the attached gif. In the end of the record playback sets to incorrect value. I update the value by the key MPNowPlayingInfoPropertyElapsedPlaybackTime from the timer block. I check…
AlexEdunov
  • 357
  • 1
  • 15
2
votes
0 answers

AVAssetWriter write image to mp4 file, but file content is only half

i want to record a window's snapshot to a mp4 file in a macOS app. start the creater with function [aMp4CreaterEntity startRecordWithSize:CGSizeMake(2320, 1080) pixelType:kCVPixelFormatType_32ARGB] run a timer 15 times per second, snapshotting the…
guojing
  • 129
  • 14
2
votes
0 answers

CMTime parameter is received with unexpected value

I'm trying to pass a CMTime value as a function parameter... My function looks like: getThumbnailForVideo:(AVAsset *)video atTime:(CMTime)time; so somewhere I'm calling [instance getThumbnailForVideo:video …
Guig
  • 9,891
  • 7
  • 64
  • 126
2
votes
2 answers

Split CMTimeRange into multiple CMTimeRange chunks

Lets assume I have a CMTimeRange constructed from start time zero, and duration of 40 seconds. I want to split this CMTimeRange into multiple chunks by a X seconds divider. So the total duration of the chunks will be the same duration as the…
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
2
votes
1 answer

Check if CMTime is in CMTimeRange

I'm trying to understand what is the correct way to check if CMTime is in range. Example: let's assume we have a video, with a duration of 20 seconds. We split this video into two CMTimeRange. from 0 seconds to 10 from 10 seconds to 20 Now, for…
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
2
votes
2 answers

Make CMTime with a very small value

I have a small integer value and I want to convert it into CMTime. The problem is that CMTime(value: _ , timeScale: _) or CMTimeMakeWithSeconds(value: _ , timeScale: _) will always return the floor so that time always equals 0.0 seconds let…
user7404038
2
votes
1 answer

periodicTimeObserver for duration countdown in AVPlayer with Swift

I have a time observer for AVPlayer that works great. Im trying to get it to countdown from the duration of the audio 0. It works and does count down now I'm just having some trouble with formatting. if you see the picture below you'll see what i…
Pippo
  • 1,439
  • 1
  • 18
  • 35
2
votes
0 answers

Edit a portion of video (using AVFoundation)

I have some code, provided below. This will take 2 videos assets, and insert the 2nd asset into the first asset. As of right now I am calling a new AVMutableComposition every time and returning a whole new composition, which is time consuming. I…
impression7vx
  • 1,728
  • 1
  • 20
  • 50
2
votes
1 answer

CMTimeGetSeconds returns 0 instead 0.0666667

Hello I'm trying to convert an integer which represents a frame rate into CMTime to be able to set minFrameDuration in AVCaptureScreenInput. Until now I have int numberOfFrames = [self convertFrameRateStringToInt:[parameters…
user1792771
  • 99
  • 13
2
votes
1 answer

AVPlayer - Rewind / Fast backward

Is it possible to fast backward / rewind an AVPlayer stream? I got fast forward working properly, but not fast backward. Any help?
Lorenz Wöhr
  • 855
  • 3
  • 14
  • 22
1
vote
1 answer

Store CMTime in CoreData?

Sorry if this been answered before, but i can't find an answer here. How do I store a CMTime value using CoreData? Thanks in advance.
Erik
  • 5,791
  • 5
  • 30
  • 45