0
这是我的问题:我想生成包含多个视频部分的视频。 对于使用后置摄像头创建的视频,一切正常,但是当我尝试从自拍相机中引入视频时,我有一半黑色的屏幕。 这里是我用来旋转,缩放,重新录制视频的代码。我想我必须得申请其他转换,但我不能找到什么..合并缩放和旋转物镜后的视频C
CGAffineTransform orientationTransform = videoAssetTrack.preferredTransform;
CGSize naturalSize = CGSizeApplyAffineTransform(videoAssetTrack.naturalSize, orientationTransform);
naturalSize.width = fabs(naturalSize.width);
naturalSize.height = fabs(naturalSize.height);
// Make sure the video is transformed properly - Apply Aspect Fill
float scale = naturalSize.width < naturalSize.height ? _renderSize.width/naturalSize.width : _renderSize.height/naturalSize.height;
CGPoint recenter;
recenter.x = (_finalSize.width - naturalSize.width * scale) * 0.5;
recenter.y = (_finalSize.height - naturalSize.height * scale) * 0.5;
// If orientationTransform rotated the video in a way that changed the orientation, switch recenter
if ((videoAssetTrack.naturalSize.width > videoAssetTrack.naturalSize.height) != (naturalSize.width > naturalSize.height)) {
typeof(recenter.x) temp = recenter.x;
recenter.x = recenter.y;
recenter.y = temp;
}
CGAffineTransform transform = CGAffineTransformConcat(CGAffineTransformConcat(CGAffineTransformMakeScale(scale, scale), CGAffineTransformMakeTranslation(recenter.x, recenter.y)), orientationTransform);
[layerInstruction setTransform:transform atTime:timeOffset];