Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anyone have an example of how to write audio and video simultaneously using AVAssetWriter?

Been trying to figure this out with zero success.

I can write video output no problem ... but once I try to introduce a second AVAssetWriterInput to include audio the final quicktime movie is jumpy with frames being loss left and right and audio constantly going in and out.

Thanks - wg

like image 895
wgpubs Avatar asked Sep 22 '10 00:09

wgpubs


People also ask

Is it possible to create a ProRes encoded mov file with assetwriter?

I started with an application that only writes video buffers to a file, and this works fine, producing a ProRes encoded .mov as expected. However when i add the Audio AssetWriterInput to the AssetWriter, the file that gets created appears to be invalid.

Do you write the audio and visual aspects of a video?

But even if your video is a single shot of someone talking, write the visual and audio aspects into your script. The script is a set of directions for whoever is shooting the video, and you want the video team to know, without a doubt, what’s supposed to be happening with both the visual and audio elements.

What are the rules for writing scripts for video and audio?

Before I go there, let’s explore some of the “rules” I often see about writing scripts for video and audio and why I’m not such a fan of them: Use shorter words instead of longer ones. Use contractions instead of full words (e.g., “can’t” instead of “cannot,” and “don’t” instead of “do not”). Use teleprompters or memorize your scripts always.

How do I write a two-column video script?

It’s easy to read and see how the video will look and sound. This is a brief two-column video script example: Add as many boxes as you need to cover all the shots in your video. Depending on the sort of video you’re making, you may need to cram everything into 15 or 30 seconds, or you could have a full three minutes or more to work with.


1 Answers

If you include source we might be able to help you more, but this is a method with which I have had success in writing many audio and video tracks to a quicktime movie – I use a single AVMutableComposition with AVMutableVideoComposition and AVAudioMix. I then write it like so:

AVAssetExportSession *session = [[[AVAssetExportSession alloc] initWithAsset:[project.composition copy] presetName:presetName] retain];
    session.outputFileType = [session.supportedFileTypes objectAtIndex:0];
    session.outputURL = [NSURL fileURLWithPath:[VeporterAppDelegate createMoviePath]];
    session.videoComposition = project.videoComposition;
    session.audioMix = project.audioMix;

    session.metadata = project.metadata;

    [session exportAsynchronouslyWithCompletionHandler:^{}];
like image 118
Peter DeWeese Avatar answered Sep 21 '22 15:09

Peter DeWeese