2

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 にフェードします)。

どんな考えでも大歓迎です!

4

2 に答える 2