bing
bing

Reputation: 1

AVAssetWriter can merge two video files

Do not tell me to use AVAssetExportSession, thank you.

I tried this, but failed.

for (int i =0; i < count; i++) {

        assetWriterInput = nil;
        assetWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings];

        NSParameterAssert(assetWriterInput);
        NSParameterAssert([assetWriter canAddInput:assetWriterInput]);

        [assetWriterInput setExpectsMediaDataInRealTime:YES];
        [assetWriter addInput:assetWriterInput];
}        
[assetWriter startWriting];

Upvotes: 0

Views: 1132

Answers (1)

James Bush
James Bush

Reputation: 1527

The sample app that shows you how to do exactly what you're talking about is AVCompositionDebugVieweriOS:

https://developer.apple.com/library/ios/samplecode/AVCompositionDebugVieweriOS/Introduction/Intro.html#//apple_ref/doc/uid/DTS40013421

I'm sure you can pare down the code to just the parts you need; but, if that's not yet where you're at with your level of understanding, let me know.

One more thing: this app not only contains the code you need, but also draws a graph of your output, showing you where you made the connection between the two clips, and any transition you may have inserted between them.

Upvotes: 1

Related Questions