7

I'm playing with the AVEditDemo project, from Apple's WWDC 2010 sample pack, and I'm trying to change the frame rate of the exported video. The video is exported using an AVMutableComposition on which the frameDuration is set like that:

videoComposition.frameDuration = CMTimeMake(1, 30); // 30 fps

For some reason, changing the 30 to 25 does not change the framerate of the video exported with the AVAssetExportSession. Does anyone have an idea why?

Atulkumar V. Jain
  • 5,102
  • 9
  • 44
  • 61
MonsieurDart
  • 6,005
  • 2
  • 43
  • 45

3 Answers3

6

The client can set sourceTrackIDForFrameTiming to kCMPersistentTrackID_Invalid and frameDuration to an appropriate value in order to specify the maximum output frame rate independent of the source track timing.

videoComposition.sourceTrackIDForFrameTiming = kCMPersistentTrackID_Invalid;
videoComposition.frameDuration = CMTimeMake(1, 30);
adiga
  • 34,372
  • 9
  • 61
  • 83
yong wei
  • 125
  • 1
  • 2
  • 1
    How did you discover that setting sourceTrackIDForFrameTiming to kCMPersistentTrackID_Invalid was an option? – Drew Mar 01 '20 at 04:39
5

replying MonsieurDart's answer: I didn't try the AVEditDemo but I'm not having this issue on iOS 8, nor did I have it on iOS 7.

I'm using a AVMutableVideoComposition and setting it as the AVAssetExportSession's videoComposition.

.
.
AVMutableVideoCompositionInstruction * instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction];
AVMutableVideoCompositionLayerInstruction *layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:videoTrack];
AVMutableVideoComposition *compositionInstruction = [AVMutableVideoComposition videoComposition];
compositionInstruction.instructions = @[instruction];
compositionInstruction.frameDuration = CMTimeMake(1, 30);
.
.    
AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:composition AVAssetExportPresetHighestQuality];
exporter.videoComposition = compositionInstruction;

where the videoTrack is a AVMutableCompositionTrack created from the asset

Oferm
  • 276
  • 4
  • 7
4

It seems that the AVAssetExportSession preset takes precedence over the AVVideoComposition frameDuration. I've opened a bug report:

http://openradar.appspot.com/11127156

Atulkumar V. Jain
  • 5,102
  • 9
  • 44
  • 61
MonsieurDart
  • 6,005
  • 2
  • 43
  • 45