Context:
Suppose I have a file video.mov which has an NTSC frame rate of 29.97. It uses drop frame for the timecodes, which means that for every minute except the 10th minute, the timecode skips forward by 2 frames.
Questions:
In Swift 5.9, I want to use AVAssetImageGenerator's image(at:) method to grab an image of the 3,450th frame of this video. The method accepts a CMTime struct, which provides a specific time in the video at which the image should be captured.
If I understand correctly, that time should be 3450 / (30000/1001) = 115.115 seconds. Expressed in integers for CMTime, that becomes: (3450 * 1001) / 30000.
Is this the correct way to handle NTSC video? I gather
CMTimeis concerned with just absolute time, not timecodes, so drop frames don't matter?Is there a better API to use (without time conversion) given that I know the exact frame that needs to be captured?
If I do NOT know the native frame rate for a video file, is
AVAsset'spreferredRateAPI the appropriate way to retrieve that?