Saturday 15 September 2012

swift - Invalid composition error (-11841) when trying to add CATextLayer to video -


I am trying to add text to a video, but it does not matter if I have an invalid structure error (-11841 ). I have followed the tutorials, have read through the thread and there is nothing wrong. I'm combining 3 videos, and an audio track and it works great. I'm trying to add text to the duration of the first video clip (videoStartAsset)

Here is the code I am using:

  var mainInstruction = AVMutableVideoCompositionInstruction VideoAssetTrack = videoStartAsset.tracksWithMediaType (AVMediaTypeVideo) [0] AVAssetTrack videoLayerInstruction.setOpacity (0.0, atTime : videoStartTimeRange .duration) mainInstruction.layerInstructions = [videoLayerInstruction] var mainCompositionInst = AVMutableVideoComposition () var Prakritikakar = video AssetTrack. naturalSize var renderWidth = naturalSize.width var renderHeight = naturalSize.height main Compojisninst Krenderskele = float (UIScreen.mainScreen (). scale) main Kanpaipment Inst. RenderSize = CGSize (width: 640.0, height: 480.0) mainCompositionInst.instructions = [mainInstruction] mainCompositionInst.frameDuration = NameTextLayer = CATextLayer () nameTextLayer.font = "font" nameTextLayer.fontSize = 100 nameTextLayer.frame on CMTimeMake (1, 30) = CGRect (X: 0.0, Y: 0.0, width: NaturalSizekwidth, height? naturalSize.height) If the nameText = nameInputText .label .text {nameTextLayer.string = "text"} else {nameTextLayer.string = "default text "} NameTextLayer.alignmentMode = kCAAlignmentCenter nameTextLayer.foregroundColor. = UIColor.whiteColor () CGColor bridesmaid overlayLayer = CALayer () overlayLayer.addSublayer (nameTextLayer) overlayLayer.frame = CGRect (X: 0.0, Y: 0.0, Width: NaturalSizekwidth, height: naturalSize.height) overlayLayer.masksToBounds = true var parentLayer = CALayer () var videoLayer = CALayer () parentLayer.frame = CGRect (X: 0.0, Y: 0.0, width: NaturalSizekwidth, height: naturalSize.height) videoLayer.frame = Sijiartiaks (X: 0.0, Y: 0.0, Width: Natural Size. Width, Height: Natural Seed.) Parent Layer. AadS Slayer (Video Laure) Parent Laure Adspair (overlay layer) is the main composition main. AnimationTool = Avivio Composercore AnimatingTool (Postprocessing ASVideoLayer: Video Layer, Inner: Parenter Layer)  

Thanks.

"itemprop =" text ">

  AVErrorInvalidVideoComposition = -11841, you tried to perform a video structure operation which supported Is not available in iOS 5.0 and later.  

You get more information about AV Foundation errors.


No comments:

Post a Comment