Compress ios video: reduce usin video size AVAssetWriter

I am successfully coding a series of images captured by AVCaptureVideoPreviewLayer AVFoundation Framework in video using AVAssetWriter and AVAssetWriterInput.

But the video size is too large, can any of you offer me a tutorial, or at least directly to me in this case, or give me the correct video output options 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;
+4
source share

Source: https://habr.com/ru/post/1538414/


All Articles