2012-07-02 40 views
2

我是從一系列圖像創建視頻。我的工作目的是創建一個不壓縮的.mov視頻。我在開發庫中看到它存在一個關鍵字「AVVideoCompressionPropertiesKey」,但我不知道如何用這個鍵指定沒有壓縮。AVAssetWriter如何創建不壓縮的mov視頻?

請問您能幫我嗎?

這是我的示例代碼:

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

回答

3

嘗試使用AVVideoCodecJPEG設置爲1.0的的NSNumber的AVVideoQualityKey值。另一種方法是指定H264,將比特率設置得非常高,並且指定關鍵幀間隔爲1(即所有關鍵幀)。

1

該鍵不是用於禁用壓縮,是爲某些編解碼器指定特定的壓縮值,如jpg或h264.I.e。

[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]]; 
     } 
0

ProRes4444視頻編解碼器是蘋果提供給未壓縮編解碼器的最接近的東西。此編解碼器不適用於iOS,僅用於編寫視頻內容OS X.

iOS無法導出未壓縮的視頻內容。