Thursday, 15 May 2014

objective c - iOS Rotating Video Using AVMutableVideoCompositionLayerInstruction -


At the moment, whenever I export a video, it appears to rotate 90 degrees right, but I'm not sure That's why that's why. My current code is:

  AVURLAsset * videoAsset = [[AVURLASet alloc] initWithURL: self.video option: zero]; AVMutableComposition * Composite = [AVMutableComposition composition]; AVMutableCompositionTrack * compositionVideoTrack = [Mixing addMutableTrackWithMediaType: AVMediaTypeVideo Favorites Track ID: kCMPersistentTrackID_Invalid]; AVAssetTrack * ClipAvideoTrack = [[Video Asset Tracks with Media Type: AVMediaType Video] The Last Object]; [CompositionVideoTrack DanteMirenz: CMTMRMMMK (KCMTimeJero, VideoAssetActuration) Keytrack: ClavidArchac Time: KCMTimeGerman Error: Zero]; [ConstructiveTrack SetPreferencesFormat: [[[VideoAssetTrackwidth Media Type: AVMidetEpe Video] ObjectItindex: 0] Favorite Transformers]]; CGSize videoSize = [Clavidiotrack natural shape]; Caller * Parentleier = [Calair layer]; CALayer * VideoLayer = [Calair Layer]; VideoLayer.frame = CGRectMake (0, 0, videoSize.width, videoSize.height); ParentLayer.frame = CGRectMake (0, 0, videoSize.width, videoSize.height); [Parentlear adblayer: video layer]; AVMutableVideoComposition * Video Comp = [AVMutableVideoComposition videoComposition]; VideoComp.renderSize = [Clipidotracrack Natural Shape]; VideoComp.frameDuration = CMTimeMake (1, 30); VideoComp.animationTool = [AVVideoCompositionCoreAnimationTool Video Composercore AnimationWith Post ProcessingAs VideoLayer: Video Layer Inner: Parent Lawer]; AVMutableVideoCompositionInstruction * Instructions = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; Instruction. Timrange = CMTMRMMM (KCMTimeJairo, Mix Editing.); AVAssetTrack * VideoTrack = [[Mix Composer Tracks with Media Type: AVMidiaTape Video] ObjectAttindex: 0]; AVMutableVideoCompositionLayerInstruction * layerInstruction = [AVMutableVideoCompositionLayerInstruction Video CompositionLayer InstructionWidgetsetTack: VideoTrack]; Instructions. Layer directive [= Object with the NSARA array: Reconstruction]; VideoComp.instructions = [Object with NSSS array: Directive]; AVAssetExport session * assetExport = [[AVAssetExportSession alloc] initWithAsset: Mix Edit Pre-defined Name: AVAssetExportPresetMediumQuality]; AssetExport.videoComposition = videoComp; NSString * videoName = @ "output.mov"; NSString * exportPath = [NstemporaryDirectory () stringBuffing string: VideoName]; Ns URL * exportURL = [NSUr File URL Thick Path: Export Path]; If ([[NSFileManager default manager] filexsteth: ExportPath]] [[NSFileManager Default Manager] Removed OpenPath: ExportPath Error: Zero]; AssetExport.outputFileType = AVFileTypeQuickTimeMovie; AssetExport.outputURL = exportURL; AssetExport.shouldOptimizeForNetworkUse = Yes; [AssetExport exportAsynchronouslyWithCompletionHandler: ^ (zero) {sending_accommon (sender_pot_man_close ()), ^ {[self-exportedDidfinish: assetXport];}); }];  

I tried to use the following code to change it, and although it technically rotates the video, it reduces the video to a square, and I do not know if it How to extend the full screen to fit:

  CGFine transformer rotation = CGPhen transcnet macotation (MOPI / 2); CGAffineTransform translateToCenter = CGFint TransformMac Tronstation (1000, 1000); CGAffineTransform mixedTransform = CZF TransFormConCat (rotation, transatlotocenter); [Layer Setting Transform: Composite from time to time: kcmimejra];  

Any advice?


No comments:

Post a Comment