我使用 [此处][1] 找到的代码将图像附加到使用UIImagePickerController
.
视频是纵向的并且播放良好,但是一旦我使用AVURLASSet
它转向横向而不是纵向,我找不到原因?
任何人都可以指出我正确的方向吗?
我的代码:
-(IBAction)addWaterMark:(id)sender {
AVURLAsset* videoAsset = [[AVURLAsset alloc]initWithURL:[NSURL fileURLWithPath:tempPath] options:nil];
AVMutableComposition* mixComposition = [AVMutableComposition composition];
AVMutableCompositionTrack *compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
AVAssetTrack *clipVideoTrack = [[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
[compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration)
ofTrack:clipVideoTrack
atTime:kCMTimeZero error:nil];
[compositionVideoTrack setPreferredTransform:[[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] preferredTransform]];
CGSize videoSize = [videoAsset naturalSize];
NSLog(@"%f %f",videoSize.width,videoSize.height);
}
此时我得到 480,360 而不是 temppath 的正确大小