mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix video color space conversion
This commit is contained in:
parent
0f9e8cdf5b
commit
57e9aa8123
@ -528,7 +528,18 @@
|
|||||||
videoComposition.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer];
|
videoComposition.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer];
|
||||||
}
|
}
|
||||||
|
|
||||||
AVAssetReaderVideoCompositionOutput *output = [[AVAssetReaderVideoCompositionOutput alloc] initWithVideoTracks:[composition tracksWithMediaType:AVMediaTypeVideo] videoSettings:@{ (id)kCVPixelBufferPixelFormatTypeKey: @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange) }];
|
NSDictionary *settings = [TGMediaVideoConversionPresetSettings videoSettingsForPreset:preset dimensions:outputDimensions];
|
||||||
|
*outputSettings = settings;
|
||||||
|
*dimensions = outputDimensions;
|
||||||
|
|
||||||
|
NSMutableDictionary *videoSettings = [[NSMutableDictionary alloc] init];
|
||||||
|
videoSettings[(id)kCVPixelBufferPixelFormatTypeKey] = @(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange);
|
||||||
|
#if TARGET_IPHONE_SIMULATOR
|
||||||
|
#else
|
||||||
|
videoSettings[AVVideoColorPropertiesKey] = settings[AVVideoColorPropertiesKey];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
AVAssetReaderVideoCompositionOutput *output = [[AVAssetReaderVideoCompositionOutput alloc] initWithVideoTracks:[composition tracksWithMediaType:AVMediaTypeVideo] videoSettings:videoSettings];
|
||||||
output.videoComposition = videoComposition;
|
output.videoComposition = videoComposition;
|
||||||
|
|
||||||
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:composition];
|
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:composition];
|
||||||
@ -543,9 +554,6 @@
|
|||||||
return [context addImageGenerator:imageGenerator];
|
return [context addImageGenerator:imageGenerator];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
*outputSettings = [TGMediaVideoConversionPresetSettings videoSettingsForPreset:preset dimensions:outputDimensions];
|
|
||||||
*dimensions = outputDimensions;
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1315,6 +1323,14 @@ static CGFloat progressOfSampleBufferInTimeRange(CMSampleBufferRef sampleBuffer,
|
|||||||
AVVideoPixelAspectRatioKey: videoAspectRatioSettings
|
AVVideoPixelAspectRatioKey: videoAspectRatioSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
NSDictionary *hdVideoProperties = @
|
||||||
|
{
|
||||||
|
AVVideoColorPrimariesKey: AVVideoColorPrimaries_ITU_R_709_2,
|
||||||
|
AVVideoTransferFunctionKey: AVVideoTransferFunction_ITU_R_709_2,
|
||||||
|
AVVideoYCbCrMatrixKey: AVVideoYCbCrMatrix_ITU_R_709_2,
|
||||||
|
};
|
||||||
|
|
||||||
|
#if TARGET_IPHONE_SIMULATOR
|
||||||
return @
|
return @
|
||||||
{
|
{
|
||||||
AVVideoCodecKey: AVVideoCodecH264,
|
AVVideoCodecKey: AVVideoCodecH264,
|
||||||
@ -1322,6 +1338,15 @@ static CGFloat progressOfSampleBufferInTimeRange(CMSampleBufferRef sampleBuffer,
|
|||||||
AVVideoWidthKey: @((NSInteger)dimensions.width),
|
AVVideoWidthKey: @((NSInteger)dimensions.width),
|
||||||
AVVideoHeightKey: @((NSInteger)dimensions.height)
|
AVVideoHeightKey: @((NSInteger)dimensions.height)
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
return @
|
||||||
|
{
|
||||||
|
AVVideoCodecKey: AVVideoCodecH264,
|
||||||
|
AVVideoCompressionPropertiesKey: codecSettings,
|
||||||
|
AVVideoWidthKey: @((NSInteger)dimensions.width),
|
||||||
|
AVVideoHeightKey: @((NSInteger)dimensions.height),
|
||||||
|
AVVideoColorPropertiesKey: hdVideoProperties
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSInteger)_videoBitrateKbpsForPreset:(TGMediaVideoConversionPreset)preset
|
+ (NSInteger)_videoBitrateKbpsForPreset:(TGMediaVideoConversionPreset)preset
|
||||||
|
Loading…
x
Reference in New Issue
Block a user