private void ProcessVideoComposition(AVMutableVideoComposition videoComposition) { var stages = new List <APLVideoCompositionStageInfo> (); foreach (AVVideoCompositionInstruction instruction in videoComposition.Instructions) { var stage = new APLVideoCompositionStageInfo(); stage.TimeRange = instruction.TimeRange; var rampsDictionary = new Dictionary <string, List <CGPoint> > (); var layerNames = new List <string> (); foreach (AVVideoCompositionLayerInstruction layerInstruction in instruction.LayerInstructions) { var ramp = new List <CGPoint> (); CMTime startTime = CMTime.Zero; float startOpacity = 1f; float endOpacity = 1f; CMTimeRange timeRange = new CMTimeRange(); while (layerInstruction.GetOpacityRamp(startTime, ref startOpacity, ref endOpacity, ref timeRange)) { if (CMTime.Compare(startTime, CMTime.Zero) == 0 && CMTime.Compare(timeRange.Start, CMTime.Zero) == 1) { ramp.Add(new CGPoint((float)timeRange.Start.Seconds, startOpacity)); } CMTime endTime = CMTime.Add(timeRange.Start, timeRange.Duration); ramp.Add(new CGPoint((float)endTime.Seconds, endOpacity)); startTime = CMTime.Add(timeRange.Start, timeRange.Duration); } NSString name = new NSString(layerInstruction.TrackID.ToString()); layerNames.Add(name); rampsDictionary [name] = ramp; } if (layerNames.Count > 1) { stage.OpacityRamps = rampsDictionary; } stage.LayerNames = layerNames; stages.Add(stage); } videoCompositionStages = stages; }
private void ProcessVideoComposition (AVMutableVideoComposition videoComposition) { var stages = new List<APLVideoCompositionStageInfo> (); foreach (AVVideoCompositionInstruction instruction in videoComposition.Instructions) { var stage = new APLVideoCompositionStageInfo (); stage.TimeRange = instruction.TimeRange; var rampsDictionary = new Dictionary<string, List<CGPoint>> (); var layerNames = new List<string> (); foreach (AVVideoCompositionLayerInstruction layerInstruction in instruction.LayerInstructions) { var ramp = new List<CGPoint> (); CMTime startTime = CMTime.Zero; float startOpacity = 1f; float endOpacity = 1f; CMTimeRange timeRange = new CMTimeRange (); while (layerInstruction.GetOpacityRamp (startTime, ref startOpacity, ref endOpacity, ref timeRange)) { if (CMTime.Compare (startTime, CMTime.Zero) == 0 && CMTime.Compare (timeRange.Start, CMTime.Zero) == 1) { ramp.Add (new CGPoint ((float)timeRange.Start.Seconds, startOpacity)); } CMTime endTime = CMTime.Add (timeRange.Start, timeRange.Duration); ramp.Add (new CGPoint ((float)endTime.Seconds, endOpacity)); startTime = CMTime.Add (timeRange.Start, timeRange.Duration); } NSString name = new NSString (layerInstruction.TrackID.ToString ()); layerNames.Add (name); rampsDictionary [name] = ramp; } if (layerNames.Count > 1) { stage.OpacityRamps = rampsDictionary; } stage.LayerNames = layerNames; stages.Add (stage); } videoCompositionStages = stages; }