AVAssetWriter如何创建没有压缩的mov视频? [英] AVAssetWriter How to create mov video with no compression?

查看:1244
本文介绍了AVAssetWriter如何创建没有压缩的mov视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一组图片创建视频。我的工作的目的是创建一个没有压缩的.mov视频。我在开发者库中看到它存在一个关键的AVVideoCompressionPropertiesKey,但我不知道如何指定没有压缩这个键。

I'am creating a video from an array of images. The purpose of my work is to create a .mov video with no compression. I have see in developer library that it exist a key "AVVideoCompressionPropertiesKey" but I don't know how to specify no compression with this key.

你能帮我吗?

以下是我的示例代码:

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];


推荐答案

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

Try using AVVideoCodecJPEG with the AVVideoQualityKey value set to a NSNumber of 1.0. Another method is to specify H264, set the bit rate to something very very high, and specify a key frame interval of 1 (i.e. all key frames).

这篇关于AVAssetWriter如何创建没有压缩的mov视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆