Video avatar fixes

This commit is contained in:
Ilya Laktyushin 2020-07-03 01:12:57 +03:00
parent 9d6d332623
commit d2f67127b7
4 changed files with 21 additions and 7 deletions

View File

@ -351,6 +351,10 @@
if (TGOrientationIsSideward(adjustments.cropOrientation, NULL)) if (TGOrientationIsSideward(adjustments.cropOrientation, NULL))
outputDimensions = CGSizeMake(outputDimensions.height, outputDimensions.width); outputDimensions = CGSizeMake(outputDimensions.height, outputDimensions.width);
if ((preset == TGMediaVideoConversionPresetProfile || preset == TGMediaVideoConversionPresetProfileHigh || preset == TGMediaVideoConversionPresetProfileVeryHigh) && MIN(outputDimensions.width, outputDimensions.height) < 160.0) {
outputDimensions = CGSizeMake(160.0, 160.0);
}
AVMutableCompositionTrack *compositionTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; AVMutableCompositionTrack *compositionTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
[compositionTrack insertTimeRange:timeRange ofTrack:videoTrack atTime:kCMTimeZero error:NULL]; [compositionTrack insertTimeRange:timeRange ofTrack:videoTrack atTime:kCMTimeZero error:NULL];

View File

@ -328,7 +328,7 @@
_previewView.clipsToBounds = true; _previewView.clipsToBounds = true;
[_previewView setSnapshotImage:_screenImage]; [_previewView setSnapshotImage:_screenImage];
[_photoEditor setPreviewOutput:_previewView]; [_photoEditor setPreviewOutput:_previewView];
[self updatePreviewView]; [self updatePreviewView:true];
if ([self presentedForAvatarCreation]) { if ([self presentedForAvatarCreation]) {
CGSize fittedSize = TGScaleToSize(_photoEditor.originalSize, CGSizeMake(1024, 1024)); CGSize fittedSize = TGScaleToSize(_photoEditor.originalSize, CGSizeMake(1024, 1024));
@ -1267,6 +1267,8 @@
strongSelf->_dotImageView.cropOrientation = strongSelf->_photoEditor.cropOrientation; strongSelf->_dotImageView.cropOrientation = strongSelf->_photoEditor.cropOrientation;
strongSelf->_dotImageView.cropMirrored = strongSelf->_photoEditor.cropMirrored; strongSelf->_dotImageView.cropMirrored = strongSelf->_photoEditor.cropMirrored;
[strongSelf->_dotImageView updateCropping:true]; [strongSelf->_dotImageView updateCropping:true];
[strongSelf updatePreviewView:false];
} }
}; };
cropController.beginTransitionIn = ^UIView *(CGRect *referenceFrame, UIView **parentView, bool *noTransitionView) cropController.beginTransitionIn = ^UIView *(CGRect *referenceFrame, UIView **parentView, bool *noTransitionView)
@ -1584,7 +1586,7 @@
{ {
__strong TGPhotoEditorController *strongSelf = weakSelf; __strong TGPhotoEditorController *strongSelf = weakSelf;
if (strongSelf != nil) if (strongSelf != nil)
[strongSelf updatePreviewView]; [strongSelf updatePreviewView:true];
}; };
_currentTabController.tabsChanged = ^ _currentTabController.tabsChanged = ^
{ {
@ -1610,10 +1612,16 @@
[self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures];
} }
- (void)updatePreviewView - (void)updatePreviewView:(bool)full
{ {
if (full)
[_previewView setPaintingImageWithData:_photoEditor.paintingData]; [_previewView setPaintingImageWithData:_photoEditor.paintingData];
[_previewView setCropRect:_photoEditor.cropRect cropOrientation:_photoEditor.cropOrientation cropRotation:_photoEditor.cropRotation cropMirrored:_photoEditor.cropMirrored originalSize:_photoEditor.originalSize];
UIImageOrientation cropOrientation = _photoEditor.cropOrientation;
if ([self presentedForAvatarCreation]) {
cropOrientation = UIImageOrientationUp;
}
[_previewView setCropRect:_photoEditor.cropRect cropOrientation:cropOrientation cropRotation:_photoEditor.cropRotation cropMirrored:_photoEditor.cropMirrored originalSize:_photoEditor.originalSize];
} }
- (void)updateEditorButtons - (void)updateEditorButtons
@ -1823,6 +1831,9 @@
if (paintingData != nil) if (paintingData != nil)
[TGPaintingData storePaintingData:paintingData inContext:self.editingContext forItem:_item forVideo:(_intent == TGPhotoEditorControllerVideoIntent)]; [TGPaintingData storePaintingData:paintingData inContext:self.editingContext forItem:_item forVideo:(_intent == TGPhotoEditorControllerVideoIntent)];
[_previewView setPaintingImageWithData:_photoEditor.paintingData];
[_previewView setPaintingHidden:false];
} }
- (void)applyEditor - (void)applyEditor

View File

@ -117,7 +117,6 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f;
TGMenuContainerView *_menuContainerView; TGMenuContainerView *_menuContainerView;
TGPaintingData *_resultData; TGPaintingData *_resultData;
UIImage *_stillImage;
TGPaintingWrapperView *_paintingWrapperView; TGPaintingWrapperView *_paintingWrapperView;

View File

@ -26,7 +26,7 @@
arc4random_buf(&fileId, sizeof(fileId)); arc4random_buf(&fileId, sizeof(fileId));
NSString *videoMp4FilePath = [tmpPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%" PRId64 ".mp4", fileId]]; NSString *videoMp4FilePath = [tmpPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%" PRId64 ".mp4", fileId]];
[[NSFileManager defaultManager] removeItemAtPath:videoMp4FilePath error:nil]; [[NSFileManager defaultManager] removeItemAtPath:videoMp4FilePath error:nil];
[[NSFileManager defaultManager] createSymbolicLinkAtPath:videoMp4FilePath withDestinationPath:video.path error:nil]; [[NSFileManager defaultManager] copyItemAtPath:video.path toPath:videoMp4FilePath error:nil];
video = [NSURL fileURLWithPath:videoMp4FilePath]; video = [NSURL fileURLWithPath:videoMp4FilePath];
} }