Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can try to add this line:</p> <pre><code>[exportAudioMixInputParameters setVolume:0.0 atTime:CMTimeMakeWithSeconds(start-0.01, 1)]; </code></pre> <p>Before:</p> <pre><code>[exportAudioMixInputParameters setVolumeRampFromStartVolume:0.0 toEndVolume:1.0 timeRange:fadeInTimeRange]; </code></pre> <p>Sample Code:</p> <pre><code>//trim CMTime startTrimTime = CMTimeMakeWithSeconds(start, 1); CMTime endTrimTime = CMTimeMakeWithSeconds(start+length, 1); CMTimeRange exportTimeRange = CMTimeRangeFromTimeToTime(startTrimTime, endTrimTime); exportSession.timeRange = exportTimeRange; //add fade in, fade out AVMutableAudioMix *exportAudioMix = [AVMutableAudioMix audioMix]; NSMutableArray* inputParameters = [NSMutableArray arrayWithCapacity:1]; NSArray *tracks = [asset tracksWithMediaType:AVMediaTypeAudio]; for(AVAssetTrack *track in tracks) { //NSLog(@"track:%@", track); CMTime startFadeInTime = startTrimTime; CMTime endFadeInTime = CMTimeMakeWithSeconds(start + 4.0, 1); CMTimeRange fadeInTimeRange = CMTimeRangeFromTimeToTime(startFadeInTime, endFadeInTime); CMTime startFadeOutTime = CMTimeMakeWithSeconds(start+length - 4.0, 1); CMTime endFadeOutTime = endTrimTime; CMTimeRange fadeOutTimeRange = CMTimeRangeFromTimeToTime(startFadeOutTime, endFadeOutTime); //AVMutableAudioMixInputParameters *exportAudioMixInputParameters = [AVMutableAudioMixInputParameters audioMixInputParameters]; AVMutableAudioMixInputParameters *exportAudioMixInputParameters = [AVMutableAudioMixInputParameters audioMixInputParametersWithTrack:track]; [exportAudioMixInputParameters setVolume:0.0 atTime:CMTimeMakeWithSeconds(start-0.01, 1)]; [exportAudioMixInputParameters setVolumeRampFromStartVolume:0.0 toEndVolume:1.0 timeRange:fadeInTimeRange]; [exportAudioMixInputParameters setVolumeRampFromStartVolume:1.0 toEndVolume:0.0 timeRange:fadeOutTimeRange]; [inputParameters addObject:exportAudioMixInputParameters]; } exportAudioMix.inputParameters = inputParameters; exportSession.audioMix = exportAudioMix; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload