相关疑难解决方法(0)

此代码通过AVAssetWriter和AVAssetWriterInputs写入视频+音频不起作用.为什么?

我一直在尝试使用AVAssetWriter和AVAssetWriterInputs编写视频+音频.

我在这个论坛上看了很多人说他们能够做到这一点,但这对我不起作用.如果我只是写视频,那么代码就能很好地完成它的工作.当我添加音频时,输出文件已损坏且无法再现.

这是我的代码的一部分:

设置AVCaptureVideoDataOutput和AVCaptureAudioDataOutput:

NSError *error = nil;

// Setup the video input
AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeVideo];
// Create a device input with the device and add it to the session.
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
// Setup the video output
_videoOutput = [[AVCaptureVideoDataOutput alloc] init];
_videoOutput.alwaysDiscardsLateVideoFrames = NO;
_videoOutput.videoSettings =
[NSDictionary dictionaryWithObject:
[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];     

// Setup the audio input
AVCaptureDevice *audioDevice     = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeAudio];
AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:&error ];     
// Setup the …
Run Code Online (Sandbox Code Playgroud)

iphone audio video avassetwriter

63
推荐指数
2
解决办法
4万
查看次数

任何人都有一个如何使用AVAssetWriter同时编写音频和视频的例子?

一直试图弄明白这一点,但没有成功.

我可以写视频输出没问题...但是一旦我尝试引入第二个AVAssetWriterInput来包含音频,最后的quicktime电影是跳跃的,帧左右丢失,音频不断进出.

谢谢 - wg

video-capture objective-c avfoundation ios4 avassetwriter

16
推荐指数
1
解决办法
3533
查看次数