English 中文(简体)
磁力孔——可能有两个平行的音频轨道?
原标题:AVMutableComposition - are 2 parallel audio tracks possible?

我成功地将录像和录音带合在一起,将其出口到新的m4v文档中。

My problem is now, that I want to mix the same video file and 2 audio files, which are two AVAssetTrack and have the same time lines, together. Like you do it in an audio editor where you can make a mixdown of two or more sound files, and you get one merged file.

这是可能的吗? 如果是,我怎么办?

此时,我刚刚听到一个声音,而不是两个声音。

顺便说一句:我的目标是“简便”在录像中增加一个声音文件,该录像已经具备了音响,并与新的音响文档相混合。 但看来,AVAssetTrack只是允许录音或录像,因此,我在原始录像中做了新的录音记录。 也许这是错误的......

事先感谢你!

问题回答

如果不看到你的法典,我们就很难帮助你。 或许这一法典有助于:

    AVMutableComposition* composition = [AVMutableComposition composition];

    AVURLAsset* videoAsset = [[AVURLAsset alloc]initWithURL:videoURL options:nil];
    AVURLAsset* audioAsset1 = [[AVURLAsset alloc]initWithURL:audioURL1 options:nil];
    AVURLAsset* audioAsset2 = [[AVURLAsset alloc]initWithURL:audioURL1 options:nil];

    AVMutableCompositionTrack *compositionVideoTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];

        NSError* error = NULL;

        [compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero,videoAsset.duration) 
                                       ofTrack:[[videoAsset tracksWithMediaType:AVMediaTypeVideo]objectAtIndex:0] 
                                        atTime:kCMTimeZero  
 AVMutableCompositionTrack *compositionAudioTrack1 = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];

        [compositionAudioTrack1 insertTimeRange:CMTimeRangeMake(kCMTimeZero,audioAsset1.duration) 
                                       ofTrack:[[audioAsset1 tracksWithMediaType:AVMediaTypeAudio]objectAtIndex:0] 
                                        atTime:kCMTimeZero
                                         error:&error];

 AVMutableCompositionTrack *compositionAudioTrack2 = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];

        [compositionAudioTrack2 insertTimeRange:CMTimeRangeMake(kCMTimeZero,audioAsset2.duration) 
                                       ofTrack:[[audioAsset2 tracksWithMediaType:AVMediaTypeAudio]objectAtIndex:0] 
                                        atTime:kCMTimeZero
                                         error:&error];

现在,这一组成只是与AVExportSession公司出口。 不要忘记释放这些资产。





相关问题
Playing a Sound With Monotouch

No matter what I try (build -> content, NSUrl, filename) I get a null exception : file not found when I try to play a .caf sound file in monotouch. //var path = NSBundle.MainBundle.PathForResource("...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

Play sound in iPhone web app with Javascript?

I m currently creating an iPhone web application for piano chords, and I wanted to add an option that would let the user press a Play button and play the selected chord. However, I m not sure how to ...

热门标签