From afe969b9012a054b50b3924918b141f784ee1cbf Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Mon, 25 Jan 2021 00:21:17 +0300 Subject: [PATCH] Fix video quality setting for captured videos --- .../PublicHeaders/LegacyComponents/TGCameraCapturedVideo.h | 1 + submodules/LegacyComponents/Sources/TGCameraCapturedVideo.m | 5 +++++ .../LegacyComponents/Sources/TGPhotoQualityController.m | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGCameraCapturedVideo.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGCameraCapturedVideo.h index 66c8693b26..a9031abd86 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGCameraCapturedVideo.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGCameraCapturedVideo.h @@ -12,6 +12,7 @@ @property (nonatomic, readonly) NSTimeInterval videoDuration; @property (nonatomic, readonly) bool isAnimation; @property (nonatomic, readonly) TGMediaAsset *originalAsset; +@property (nonatomic, readonly) CGSize dimensions; - (instancetype)initWithURL:(NSURL *)url; diff --git a/submodules/LegacyComponents/Sources/TGCameraCapturedVideo.m b/submodules/LegacyComponents/Sources/TGCameraCapturedVideo.m index c8aba55d23..82c61bb415 100644 --- a/submodules/LegacyComponents/Sources/TGCameraCapturedVideo.m +++ b/submodules/LegacyComponents/Sources/TGCameraCapturedVideo.m @@ -157,6 +157,11 @@ return _cachedSize; } +- (CGSize)dimensions +{ + return [self originalSize]; +} + - (NSTimeInterval)videoDuration { return [self originalDuration]; diff --git a/submodules/LegacyComponents/Sources/TGPhotoQualityController.m b/submodules/LegacyComponents/Sources/TGPhotoQualityController.m index 74fb8df88c..ad9327dbb4 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoQualityController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoQualityController.m @@ -128,8 +128,8 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f; CGSize dimensions = CGSizeZero; if ([self.item isKindOfClass:[TGMediaAsset class]]) dimensions = ((TGMediaAsset *)self.item).dimensions; -// else if ([self.item isKindOfClass:[TGCameraCapturedVideo class]]) -// dimensions = [((TGCameraCapturedVideo *)self.item).avAsset tracksWithMediaType:AVMediaTypeVideo].firstObject.naturalSize; + else if ([self.item isKindOfClass:[TGCameraCapturedVideo class]]) + dimensions = ((TGCameraCapturedVideo *)self.item).dimensions; if (!CGSizeEqualToSize(dimensions, CGSizeZero)) _quality.maximumValue = [TGMediaVideoConverter bestAvailablePresetForDimensions:dimensions] - 1;