AVAssetWriter如何创建MOV视频无压缩?(AVAssetWriter How to cr

2019-06-25 23:21发布

我'从图像阵列创建视频。 我工作的目的是建立一个.mov影片无压缩。 我已经在开发商图书馆看到它存在一个关键的“AVVideoCompressionPropertiesKey”但我不知道如何指定与此键无压缩。

请问你能帮帮我吗?

下面是我的示例代码:

NSDictionary *videoCleanApertureSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                            [NSNumber numberWithInt:320], AVVideoCleanApertureWidthKey,
                                            [NSNumber numberWithInt:480], AVVideoCleanApertureHeightKey,
                                            [NSNumber numberWithInt:10], AVVideoCleanApertureHorizontalOffsetKey,
                                            [NSNumber numberWithInt:10], AVVideoCleanApertureVerticalOffsetKey,
                                            nil];

NSDictionary *codecSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                               [NSNumber numberWithInt:960000], AVVideoAverageBitRateKey,
                               [NSNumber numberWithInt:1],AVVideoMaxKeyFrameIntervalKey,
                               videoCleanApertureSettings, AVVideoCleanApertureKey,
                               nil];


NSDictionary *videoOutputSettings = [NSDictionary dictionaryWithObjectsAndKeys:AVVideoCodecH264, AVVideoCodecKey,codecSettings,AVVideoCompressionPropertiesKey, [NSNumber numberWithInt:size.width], AVVideoWidthKey,
                                     [NSNumber numberWithInt:size.height], AVVideoHeightKey, nil];

self.videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoOutputSettings];

Answer 1:

尝试使用AVVideoCodecJPEG设置为1.0的的NSNumber的AVVideoQualityKey值。 另一种方法是指定H264,设置比特率的东西非常非常高,并指定为1的关键帧间隔(即,所有关键帧)。



Answer 2:

这关键是不要禁用压缩,是为某些编解码器指定特定的压缩值,如JPG或H264 .IE

    [videoSettings addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
                                                 AVVideoCodecH264, AVVideoCodecKey,
                                                 nil]];

        NSMutableDictionary* videoCompressionSettings = [NSMutableDictionary dictionary];

        if ([[Preferences instance] recordingH264Keyframes] > 0) {
            [videoCompressionSettings addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
                                                     [NSNumber numberWithInt:[[Preferences instance] recordingH264Keyframes]], AVVideoMaxKeyFrameIntervalKey,
                                                     nil]];
        }

        if ([[Preferences instance] recordingH264Bitrate] > 0) {
            [videoCompressionSettings addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
                                                     [NSNumber numberWithInt:[[Preferences instance] recordingH264Bitrate]*1000], AVVideoAverageBitRateKey,
                                                     nil]];
        }

        if ([videoCompressionSettings count]) {
            [videoSettings addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:videoCompressionSettings,AVVideoCompressionPropertiesKey,nil]];
        }


Answer 3:

该ProRes4444视频编解码器是最接近苹果提供未压缩编解码器。 该编解码器是不适用于iOS编写的视频内容仅OS X.

iOS上导出视频内容未压缩这是不可能的。



文章来源: AVAssetWriter How to create mov video with no compression?