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
1
vote
0 answers

define video url as the uiview in your class

My swift code should be able to take a snapshot of a video and then take that image and display in a uiimageview. Instead of using a online link I just want the url to be the uiview in my class.So the video url should be previewView not the https…
user12655184
1
vote
1 answer

Trying to append CVPixelBuffers to AVAssetWriterInputPixelBufferAdaptor at the intended framerate

I'm trying to append CVPixelBuffers to AVAssetWriterInputPixelBufferAdaptor at the intended framerate, but it seems to be too fast, and my math is off. This isn't capturing from the camera, but capturing changing images. The actual video is much to…
Chewie The Chorkie
  • 4,896
  • 9
  • 46
  • 90
1
vote
0 answers

Retrieving a pixel buffer from varying times using CMTimeAdd?

I am currently using a CADisplayLink to grab the current pixel buffer from an AVPlayerItemVideoOutput. The display link is updating like so; func displayLinkUpdated(link: CADisplayLink) { let time = output.itemTime(forHostTime:…
ZbadhabitZ
  • 2,753
  • 1
  • 25
  • 45
1
vote
1 answer

AVAssetWriter startSessionAtSourceTime not accepting CMTIme value

My app is designed to record video & analyze the frames generated under iOS 11.4, using Xcode 10.0 as IDE. Succeeded in recording video using AVCaptureMovieFileOutput, but need to analyze frames so transitioned to AVAssetWriter and modeled code…
Eric
  • 43
  • 7
1
vote
1 answer

save CMTime in core data + Xcode8 + swift3

I declared two attributes (currentTime and fullTime) as Transformable in data model as shown below. How to save data in this attribute? Do I need to convert to NSData first? or any other way?
pkc456
  • 8,350
  • 38
  • 53
  • 109
1
vote
0 answers

AVQueuePlayer perform action when currentTime is 'n' seconds from duration

I need to add a CABasicAnimation to an AVPlayerLayer when an AVQueuePlayer's playerItem is one second from finishing (playerItem's duration - 1). It's a basic crossfade. I just can't seem to figure out how to tell when I've arrived at the right…
se_puede_dev
  • 585
  • 7
  • 16
1
vote
1 answer

addPeriodicTimeObserver Swift CMTIME

func addPeriodicTimeObserver(forInterval interval: CMTime, queue: DispatchQueue?, using block: @escaping (CMTime) -> Void) -> Any The code snippet says , the interval will invoke the block every 0.5 seconds // Invoke callback every half second let…
NNikN
  • 3,720
  • 6
  • 44
  • 86
1
vote
1 answer

Showing video frames without using play method in iOS

I am trying to understand the functioning of CMTime and fps in a video file. I am trying to present each and every frame of a video in an AVPlayer using a for loop. I know this task can be easily done using the play method of AVPlayer. But I want to…
maven25
  • 231
  • 2
  • 12
1
vote
1 answer

Trying to split a video with `AVAssetExportSession`

I am trying to split a video into 4 second chunks with AVAssetExportSession. The initial split works and returns a 8mb/4 second chunk. But the second returns 12mb which is incorrect when the original video os only 18mb. - (void) splitVideo{ …
Peter
  • 1,053
  • 13
  • 29
1
vote
1 answer

avplayer finishing song on seekToTime

I'm trying to have avPlayer restart the current song when the skip back button is selected if it's after about 5 seconds into the song, and jump to times according to where the slider is moved to. Here's my code for these functions: @IBAction func…
Nick
  • 155
  • 1
  • 2
  • 14
1
vote
1 answer

Video format Timecode for avplayer ios

I'm trying to make a video timecode with a "video format": MM:SS:FF Any help would be greatly appreciated
guillaumeD
  • 73
  • 6
1
vote
0 answers

Create a file which enables random access using CMTime

I am currently seeking a solution whereby I can store accelerometer data into a file and retrieve the results by indexing into a file by CMTime. This way I can pass in a time value like 1.5 seconds and retrieve the motion data (stored as a plain…
iOScoder
  • 181
  • 1
  • 12
1
vote
0 answers

Create video from UIImages in objective

I used This code for create video from images. it will create perfectly for fix time for one image. but my problem is to create video for not fixed timimg of one frame. this is my code. imageArray is array of all images and in array there are time…
1
vote
0 answers

Take the thumbnail image at specified using AVAssetImageGenerator

I was taking thumbnail image using AVAssetImageGenerator by specifying CMTimeMakeWithSeconds as (0.0, 600). It's working fine but I didn't understand the CMTime. I read the documentation but it's still not clear. Suppose I want to take the…
sunny
  • 131
  • 1
  • 10
1
vote
0 answers

to cut song with millisecond precision

I can cut a song in range start time to duration, bot are float. But i get only seconds in final song. CMTime sTime=CMTimeMake(startTime*1000, 1000); CMTime eTime=CMTimeMake(duration*1000, 1000); CMTimeRange editRange =…
Durgaprasad
  • 1,910
  • 2
  • 25
  • 44