AVComposition トラック (ビデオのオーディオ トラック) をフェードアウトしようとしています。
最初は問題なくフェードアップできますが、最後にフェードアウトするのに苦労しています。これが私のコードです:
AVMutableAudioMixInputParameters *audioMixParameters = [AVMutableAudioMixInputParameters audioMixInputParametersWithTrack:compositionAudioTrack];
[audioMixParameters setVolume:0.0 atTime:kCMTimeZero];
[audioMixParameters setVolumeRampFromStartVolume:0.0 toEndVolume:1.0 timeRange:CMTimeRangeMake(kCMTimeZero, CMTimeMake(150, kVideoFPS))];
CMTime fadeOutBegin = CMTimeMake((length - 5) * kVideoFPS, kVideoFPS);
[audioMixParameters setVolumeRampFromStartVolume:1.0 toEndVolume:0.0 timeRange:CMTimeRangeMake(fadeOutBegin, totalDuration)];
AVMutableAudioMix *audioMix = [AVMutableAudioMix audioMix];
audioMix.inputParameters = [NSArray arrayWithObject:audioMixParameters];
length
秒単位のビデオの長さである NSUInteger です。
totalDuration
タイムスケールのビデオの合計再生時間の CMTime です。kVideoFPS
kVideoFPS
値が 30 の定数
私の目標は、作曲の終わりから 5 秒後にフェードアウトを開始することです。CMTimeMakeWithSeconds など、あらゆる種類のことを試しました。フェードインの値も逆にしましたが、うまく機能します (開始時にボリュームを 1.0 から 0.0 にフェードします)。
どんな考えでも大歓迎です!