-1

我正在使用AVCam苹果创建用于视频录制的自定义相机,但我想实现在录制时将视频静音的功能,任何人都知道吗?

4

1 回答 1

1

尝试使用以下代码:

 AVURLAsset *asset = [[avPlayer currentItem] asset];
NSArray *audioTracks = [asset tracksWithMediaType:AVMediaTypeAudio];

// Mute all the audio tracks
NSMutableArray *allAudioParams = [NSMutableArray array];
for (AVAssetTrack *track in audioTracks) {
    AVMutableAudioMixInputParameters *audioInputParams =    [AVMutableAudioMixInputParameters audioMixInputParameters];
    [audioInputParams setVolume:0.0 atTime:kCMTimeZero];
    [audioInputParams setTrackID:[track trackID]];
    [allAudioParams addObject:audioInputParams];
}
AVMutableAudioMix *audioZeroMix = [AVMutableAudioMix audioMix];
[audioZeroMix setInputParameters:allAudioParams];

[[avPlayer currentItem] setAudioMix:audioZeroMix];

另一种方式是

阅读这个问题AVFoundation,如何在 captureStillImageAsynchronouslyFromConnection 时关闭快门声音?

于 2013-03-22T06:27:57.130 回答