Video Compression ios : Reduce the size of a video usin AVAssetWriter

老子叫甜甜 提交于 2019-12-04 23:44:58

问题


I am Successful in encoding a series of image captured by AVCaptureVideoPreviewLayer of AVFoundation Framework into a Video using AVAssetWriter and AVAssetWriterInput.

But the size of the video is too large, Can anyone of you suggest me a tutorial or atleast a direct me in this case or give me the correct Video output Settings for video compression.

I am using the following 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;

来源:https://stackoverflow.com/questions/23342964/video-compression-ios-reduce-the-size-of-a-video-usin-avassetwriter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!