I try to capture video:
https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/04_MediaCapture.html#//apple_ref/doc/uid/TP40010188-CH5-SW26
var maxDuration : CMTime = CMTimeMake(seconds, preferredTimeScale)
aMovieFileOutput.maxRecordedDuration = CMTimeMake(seconds, preferredTimeScale)
1 row have error: Use of module 'CMTime' as a type
2 row have error: Use of unresolved identifier 'CMTimeMake'
What I do wrong?
1) CMTimeMake(1,10) means duration of 1 second and timescale of 10, or 10 frames per second. This means 1s duration of video with 10 frames? 2) CMTime lastTime=CMTimeMake(1,10); CMTime frameTime=CMTimeMake(1, 10); CMTime currentTime=CMTimeAdd(lastTime, frameTime)
Overview. Core Media represents time as a rational value, with a time value as the numerator and timescale as the denominator. The structure can represent a specific numeric time in the media timeline, and can also represent nonnumeric values like invalid and indefinite times or positive and negative infinity.
CMTime
and CMTimeMake
are defined in the "CoreMedia" module, therefore you have to
import CoreMedia
Then this compiles without problems:
let seconds : Int64 = 10
let preferredTimeScale : Int32 = 1
let aMovieFileOutput = AVCaptureMovieFileOutput()
let maxDuration : CMTime = CMTimeMake(seconds, preferredTimeScale)
aMovieFileOutput.maxRecordedDuration = maxDuration
Update for Swift 3:
let maxDuration = CMTime(seconds: Double(seconds), preferredTimescale: 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With