4

我正在从一组图像创建一个视频。我工作的目的是创建一个没有压缩的 .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];
4

3 回答 3

4

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

于 2012-07-03T23:51:58.203 回答
3

该键不是用于禁用压缩,而是为某些编解码器指定特定的压缩值,例如 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]];
        }
于 2012-09-26T15:14:54.697 回答
0

ProRes4444 视频编解码器是 Apple 提供的最接近未压缩编解码器的产品。此编解码器不适用于 iOS 上仅用于编写视频内容的 OS X。

在 iOS 上无法导出未压缩的视频内容。

于 2015-08-01T13:37:14.277 回答