我记录一些视频与自定义CaptureSessionManager和上午根据装置方向旋转所述预览层(否则,预览层是在横长的左/右颠倒要么)。这工作到目前为止。但是......IO <S AVAssetTrack视频取向
当我尝试播放视频,我用下面的代码来确定视频的方向:
AVAssetTrack *videoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
CGSize size = [videoTrack naturalSize];
CGAffineTransform txf = [videoTrack preferredTransform];
if (size.width == txf.tx && size.height == txf.ty)
return UIInterfaceOrientationLandscapeRight;
else if (txf.tx == 0 && txf.ty == 0)
return UIInterfaceOrientationLandscapeLeft;
else if (txf.tx == 0 && txf.ty == size.width)
return UIInterfaceOrientationPortraitUpsideDown;
else
return UIInterfaceOrientationPortrait;
但结果都是一样的,不管它的左边或右边。
我用这个代码来获取输出:
AVAssetTrack *videoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
CGSize size = [videoTrack naturalSize];
CGAffineTransform txf = [videoTrack preferredTransform];
NSLog(@"Transformation a %f - b %f - c %f - d %f", txf.a, txf.b, txf.c, txf.d);
NSLog(@"Transformation tx %f - ty %f", txf.tx, txf.ty);
NSLog(@"Size width: %f - height: %f", size.width, size.height);
导致:
Transformation a -1.000000 - b 0.000000 - c 0.000000 - d -1.000000
Transformation tx 1920.000000 - ty 1080.000000
Size width: 1920.000000 - height: 1080.000000
为左,右方向的录音。
任何想法?
不错的代码片断来确定视频方向,谢谢! –