I am recording a video in my application. When a video is being recorded, I want the user to view the recording using the controls to change the volume and pan the audio track. To watch the video, I use AVMutableComposition and add AVAsset from the local URL of the recorded file and use the composition as AVPlayerItem to play through AVPlayer . I do this because I want to add volume and panoramas (") (") to the soundtracks in the composition, and then export the entire composition.
Playback works fine, but I can't find a way to add such “filters” (to change the volume or pan of AVAssetTrack or anything else at that level). So far, I have been able to change the volume during playback using this:
NSMutableArray *audioParam = [NSMutableArray array]; AVMutableAudioMixInputParameters *audioInputParams = [AVMutableAudioMixInputParameters audioMixInputParameters]; [audioInputParams setVolume:volumeSlider.value atTime:kCMTimeZero]; [audioInputParams setTrackID:[audioTrack trackID]]; [audioParam addObject:audioInputParams]; AVMutableAudioMix *audioMix = [AVMutableAudioMix audioMix]; [audioMix setInputParameters:audioParam]; [playerItem setAudioMix:audioMix];
Here, I believe, I am only changing the presentation of the composition, not the composition itself. When the user is satisfied with the volume level and panning, he should click “Accept” and I will export the composition to a separate movie file (IE this will not affect the composition if I change the player’s volume in this way).
Is there a way to add the original movie to AVComposition, change the volume / pan of the sound and export to a new file with new information?
I am also, as already mentioned, looking for this to pan an audio stereo or monaural track, but I cannot find anything. The only mention of panning in Apple Docs is the use of AVAudioPlayer , which I cannot use as it is a video file. Also, changing the pan in the player will not do anything good, as I explained using the volume. Is there no way to change the panning through AVAsset , AVAssetTrack , AVComposition or something like that?
I thought that I would have to do it manually, reducing the volume of each channel for a stereo audio track, but I also can not find a way to do this.
Simply put, I’m looking for a way to change the volume level and pan (left / right) of the audio track of one video (previously mentioned video during preview / playback), and then you can export this video to a new video file, which will then have this new information about volume and panorama as source information.
Example:
1. Record a video.
2. Preview the video.
3. Set the panning sound to the left (audio in the left channel only) and Volume up to 20%
4. Export video with new information
5. If I upload this video file to the Internet now, and someone downloads it to any device / computer, it will only have sound in the left speaker, and it will be quite low.