Setting AVMutableComposition frameDuration

I am playing with the AVEditDemo project, from the Apple WWDC 2010 sample package, and I am trying to change the frame rate of the exported video. The video is exported using AVMutableComposition , which is set to frameDuration:

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

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

+5
source share
3 answers

Preset AVAssetExportSession take precedence over AVVideoComposition frameDuration . I opened an error report:

http://openradar.appspot.com/11127156

+4
source

Responding to MonsieurDart's answer: I have not tried AVEditDemo , but I do not have this problem on iOS 8, and I did not have it on iOS 7.

I use AVMutableVideoComposition and set it as AVAssetExportSession's video AVAssetExportSession's .

 . . 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 videoTrack is an AVMutableCompositionTrack created from an asset

+4
source

The client can set sourceTrackIDForFrameTiming to kCMPersistentTrackID_Invalid and frameDuration to the appropriate value to indicate the maximum output frame rate independent of the synchronization of the original track.

 videoComposition.sourceTrackIDForFrameTiming = kCMPersistentTrackID_Invalid; videoComposition.frameDuration = CMTimeMake(1, 30); 
0
source

Source: https://habr.com/ru/post/908825/


All Articles