diff --git a/MP42/MP42AVFImporter.m b/MP42/MP42AVFImporter.m index 5a0ff11..d3d553b 100644 --- a/MP42/MP42AVFImporter.m +++ b/MP42/MP42AVFImporter.m @@ -253,6 +253,11 @@ MP42_OBJC_DIRECT_MEMBERS videoTrack.matrixCoefficients = 9; } } + + CFBooleanRef colorRange = CMFormatDescriptionGetExtension(formatDescription, kCMFormatDescriptionExtension_FullRangeVideo); + if (colorRange) { + videoTrack.colorRange = CFBooleanGetValue(colorRange); + } } newTrack = videoTrack; diff --git a/MP42/MP42MkvImporter.m b/MP42/MP42MkvImporter.m index d5ab104..4d4651e 100644 --- a/MP42/MP42MkvImporter.m +++ b/MP42/MP42MkvImporter.m @@ -150,7 +150,7 @@ MP42_OBJC_DIRECT_MEMBERS } if (mkvTrack->AV.Video.Colour.Range) { - videoTrack.colorRange = mkvTrack->AV.Video.Colour.Range; + videoTrack.colorRange = mkvTrack->AV.Video.Colour.Range == 2 ? 1 : 0; } newTrack = videoTrack; diff --git a/MP42/MP42VideoTrack.m b/MP42/MP42VideoTrack.m index 135bf01..e6274c5 100644 --- a/MP42/MP42VideoTrack.m +++ b/MP42/MP42VideoTrack.m @@ -187,6 +187,7 @@ static uint32_t convertToFixedPoint(CGFloat value) { } else { MP4AddColr(fileHandle, self.trackId, _colorPrimaries, _transferCharacteristics, _matrixCoefficients); + MP4SetTrackIntegerProperty(fileHandle, self.trackId, "mdia.minf.stbl.stsd.*.colr.full_range_flag", _colorRange); } } else { @@ -269,6 +270,13 @@ static uint32_t convertToFixedPoint(CGFloat value) { self.edited = YES; } +- (void)setColorRange:(uint16_t)colorRange +{ + self.updatedProperty[@"colr"] = @YES; + _colorRange = colorRange; + self.edited = YES; +} + - (void)setHSpacing:(uint64_t)newHSpacing { _hSpacing = newHSpacing;