Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
877 views
in Technique[技术] by (71.8m points)

ios - AVAssetWriter How to create mov video with no compression?

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.

Could you help me please?

Here is my sample code :

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];
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...