0

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 this in CoreData?

I can't use a NSNumber as the float type round the Float64 way to much. 1.200000 is 1.0000 when I create my NSNumber.

Thanks in advance

Erik
  • 5,791
  • 5
  • 30
  • 45
  • `-[NSNumber numberWithDouble:]` rounds it too much when you access the `doubleValue` (not `floatValue`)? – Joe Mar 13 '12 at 14:05
  • I'm afraid not, Float64 duration = CMTimeGetSeconds(asset.duration); self.videoTrack.duration = [NSNumber numberWithDouble:duration]; NSLog(@"First Duration: %f, %f", duration, [self.videoTrack.duration doubleValue]); prints: First Duration: 1.295000, 1.000000 – Erik Mar 13 '12 at 14:12
  • It is highly likely that that the `videoTrack` adjust the duration to a nice round number that makes since for video playback. Try creating an `NSNumber` and printing it without setting it to the duration propery and you will probably get the exact same result. – Joe Mar 13 '12 at 15:08
  • in my core data model file i accidentally made the duration an integer. thanks for pointing that out! Fixed! If you give it as a answer to the question i will mark it as a correct answer. thanks! – Erik Mar 13 '12 at 17:00

1 Answers1

1

Based on your comments it is highly likely that that the videoTrack object will adjust the duration to a nice round number that makes since for video playback. Try creating an NSNumber and printing it without setting it to the duration property and you will probably get the exact same result. Also make sure the data type is set to a Double in the CoreData model.

Joe
  • 56,979
  • 9
  • 128
  • 135