How to merge video and audio files?

前端 未结 1 1584
慢半拍i
慢半拍i 2021-01-03 12:25

My question is: How to merge video and audio files that has almost the same duration?

I searched and got some answers to this question. However when I try the code t

1条回答
  •  一生所求
    2021-01-03 12:54

    (Answered by the OP by an edit in the question. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )

    The OP wrote:

    I solved my problem.

    For the ones who have same problem as I did, here is the simple solution:

    a.Delete the following code:

    CMTime start=CMTimeMake(0, 600);
    CMTime duration=CMTimeMake(600, 600);
    CMTimeRange range=CMTimeRangeMake(start, duration);
    exporter.timeRange=range;
    

    b.(optional)Rewrite completion handler:

    [exporter exportAsynchronouslyWithCompletionHandler:^{ 
        switch ([exporter status]) {
            case AVAssetExportSessionStatusFailed:
                NSLog(@"Export failed: %@", [[exporter error] localizedDescription]);
                break;
            case AVAssetExportSessionStatusCancelled:
                NSLog(@"Export canceled");
                break;
            default:
                break;
        } 
    }];
    

    c.Then wait long enough for the program to complete writing.

    0 讨论(0)
提交回复
热议问题