h 264硬件编码/解码适用于IOS(IPhone / Ipad)?

时间:2012-01-23 06:46:37

标签: iphone ios avfoundation h.264

我使用AVFoundation框架在ios中进行了实时视频处理, this link的帮助。我测试过它工作正常。现在我想使用h264编码和解码[在绘制之前] .i尝试从AVCaptureSession获取h264编码数据,所以我在开始捕获之前在AVCaptureSession的视频设置中设置了AVVideoCodecH264。

  

NSDictionary * videoSettings = [NSDictionary   dictionaryWithObjectsAndKeys:值,钥匙,AVVideoCodecH264,AVVideoCodecKey,   零];   [captureOutput setVideoSettings:videoSettings];

上面的代码不会对输出缓冲区产生任何变化,同样的缓冲区格式就像之前一样。如何完成我的要求?可能吗 ?如果是这样请帮助我开始,在ios中使用h264。

1 个答案:

答案 0 :(得分:1)

无法直接访问已编码的关键帧。您可以在此处找到一些有见地的评论:https://stackoverflow.com/questions/4399162/how-to-stream-live-video-from-iphone-to-a-media-server-like-wowza

一对AVVideoCodecH264, AVVideoCodecKey可用作<{p>中的outputSettings中的参数

NSError *error = nil;
NSDictionary *outputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                AVVideoCodecH264, AVVideoCodecKey, nil];

AVAssetWriterInput *assetWriterInput = [[AVAssetWriterInput alloc]
                                   initWithMediaType:AVMediaTypeVideo
                                      outputSettings:outputSettings];
AVAssetWriter *assetWriter = [[AVAssetWriter alloc] initWithURL:fileURL
                                                       fileType:AVFileTypeMPEG4
                                                          error:&error];
if (!error && [assetWriter canAddInput:assetWriterInput])
  [assetWriter addInput:assetWriterInput];