视频压缩ios:使用AVAssetWriter减小视频的大小

时间:2014-04-28 13:52:28

标签: ios video compression reduce avassetwriter

我成功地将AVFoundation Framework的AVCaptureVideoPreviewLayer捕获的一系列图像编码为使用AVAssetWriter和AVAssetWriterInput的视频。

但是视频的大小太大了,你们中的任何人都可以向我推荐一个教程或至少直接的我 在这种情况下,或者为我提供视频压缩的正确视频输出设置。

我正在使用以下VideoOutputSetting。

videoOutputSettings = @{
                          AVVideoCodecKey: AVVideoCodecH264,
                          AVVideoWidthKey: [NSNumber numberWithInt:width],
                          AVVideoHeightKey: [NSNumber numberWithInt:height],
                          AVVideoCompressionPropertiesKey: @{
                                  AVVideoAverageBitRateKey: [NSNumber numberWithInt:bitrate],
                                  AVVideoMaxKeyFrameIntervalKey: @(150),
                                  AVVideoProfileLevelKey: AVVideoProfileLevelH264BaselineAutoLevel,
                                  AVVideoAllowFrameReorderingKey: @NO,
                                  AVVideoH264EntropyModeKey: AVVideoH264EntropyModeCAVLC,
                                  AVVideoExpectedSourceFrameRateKey: @(30),
                                  AVVideoAverageNonDroppableFrameRateKey: @(30)
                                  }
                          };
    videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings];
    _videoWriterInput.expectsMediaDataInRealTime = YES;

0 个答案:

没有答案