-
Hi and thanks for making this repo. Would you please provide an example of how to write timecode onto a MOV file with your SDK? And is this possible to do while recording with an AVCaptureSession, or does it have to be added to the file after recording? Thank you again, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 13 replies
-
Currently timecode tracks can be modified on I'm working on a demo project that will show how to modify a QuickTime video's timecode track, as well as seek an AVPlayer to timecode. The feature may become more versatile in future, as time allows. I'm not very familiar with For now, this is the method to (over)write a timecode track. Because of limitations of AVFoundation, it may involve saving the video file to disk more than once depending on your workflow. This is one way to make an let movie = AVMovie( ... )
let mutableMovie = movie.mutableCopy() as! AVMutableMovie Then add/replace the timecode track: // replace existing timecode track if it exists, otherwise add a new timecode track
try mutableMovie.replaceTimecodeTrack(
startTimecode: Timecode(TCC(h: 0, m: 59, s: 58, f: 00), at: ._24),
duration: mutableMovie.durationTimecode(),
fileType: .mov
) Finally, the new file can be saved back to disk using let export = AVAssetExportSession(
asset: mutableMovie,
presetName: AVAssetExportPresetPassthrough
)
export.outputFileType = .mov
export.outputURL = // new file URL on disk
export.exportAsynchronously {
// completion handler
} |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Thanks again for helping. With mutableMovie.timecodeFrameRate() I get the same error on this file, not on the others: "The operation couldn’t be completed. (TimecodeKit.Timecode.MediaParseError error 0.)" The strange thing is that ffprobe and QuickTime-player on a mac, as well as Photos on an iPhone, all say that the file has 25 fps. |
Beta Was this translation helpful? Give feedback.
Currently timecode tracks can be modified on
AVMutableMovie
. It's a new feature so there isn't really any documentation quite yet.I'm working on a demo project that will show how to modify a QuickTime video's timecode track, as well as seek an AVPlayer to timecode.
The feature may become more versatile in future, as time allows. I'm not very familiar with
AVCaptureSession
but maybe there's potential to add methods for it as well.For now, this is the method to (over)write a timecode track. Because of limitations of AVFoundation, it may involve saving the video file to disk more than once depending on your workflow.
This is one way to make an
AVMovie
into a mutableAVMutableMovie
if needed: