J'ai réglé un fichier audio pour une durée particulière en utilisant AVAssetExportSession et j'obtiens également l'audio rogné.Effet Fade In, Fade Out dans l'audio En utilisant AVAssetExportSession dans ios
Mais mon problème est que je veux ajouter un fondu entrant et un effet de fondu dans mon audio. Faites-moi savoir, comment puis-je résoudre ce problème? Toute aide sera appréciée.
codepour l'audio parage est ici--
- (void)trimAudio:(NSString *)inputAudioPath audioStartTime:(float)sTime audioEndTime:(float)eTime outputPath:(NSString *)outputFilePath mode:(NSInteger)kSelectionMode
{
@try
{
AVAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:inputAudioPath] options:nil];
//Create the session with assets
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:asset presetName:AVAssetExportPresetAppleM4A];
//Set the output url
exportSession.outputURL = [NSURL fileURLWithPath:outputFilePath];
// Trim video in a particular duration
CMTime startTime = CMTimeMake((int)(floor(sTime * 100)), 100);
CMTime stopTime = CMTimeMake((int)(ceil(eTime * 100)), 100);
CMTimeRange range = CMTimeRangeFromTimeToTime(startTime, stopTime);
exportSession.timeRange = range;
exportSession.outputFileType = AVFileTypeAppleM4A;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch (exportSession.status) {
case AVAssetExportSessionStatusCompleted:{
NSLog(@"Export Complete");
if(UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(exportSession.outputURL.path)){
UISaveVideoAtPathToSavedPhotosAlbum(exportSession.outputURL.path, nil, nil, nil);
if ([self.delegate respondsToSelector:@selector(trimDidSucceed:mode:)]) {
[self.delegate trimDidSucceed:outputFilePath mode:kTrimAudio];
}
else{
[self.delegate trimDidFail:exportSession.error];
}
}
break;
}
case AVAssetExportSessionStatusFailed:{
NSLog(@"Export Error: %@", [exportSession.error description]);
break;
}
case AVAssetExportSessionStatusCancelled:
NSLog(@"Export Cancelled");
break;
default:
break;
}
}];
exportSession = nil;
}
@catch (NSException * e)
{
NSLog(@"Exception Name:%@ Reason:%@",[e name],[e reason]);
}
}
Souhaitez-vous augmenter ou diminuer le volume de certaines plages audio? – Lion
Oui, exactement je le veux. –
pleae w8 @NehaPurwar j'écris –