public void RemoveClipEventHandlers() { int count = 0; EventHandler incrementBefore = delegate { count++; }; EventHandler <AddedEffectEventArgs> incrementAfter = delegate { count++; }; using (ITimeline timeline = new DefaultTimeline()) { IClip clip = timeline.AddAudioGroup().AddTrack().AddClip("testinput.wav", GroupMediaType.Audio, InsertPosition.Absolute, 0, 0, -1); clip.AddedEffect += incrementAfter; clip.AddingEffect += incrementBefore; clip.AddEffect(0, 2, StandardEffects.CreateDefaultBlur()); Assert.AreEqual(2, count); count = 0; clip.AddedEffect -= incrementAfter; clip.AddingEffect -= incrementBefore; clip.AddEffect(0, 2, StandardEffects.CreateDefaultBlur()); Assert.AreEqual(0, count); } }
public void AddEffectSetsApropriateContainer() { using (ITimeline timeline = new DefaultTimeline()) { EffectDefinition def = StandardEffects.CreateDefaultBlur(); IGroup group = timeline.AddVideoGroup(24, 100, 100); IEffect groupEffect = group.AddEffect(0, 10, def); Assert.AreSame(group, groupEffect.Group); Assert.AreSame(group, groupEffect.Container); ITrack track = group.AddTrack(); IEffect trackEffect = track.AddEffect(0, 10, def); Assert.AreSame(group, trackEffect.Group); Assert.AreSame(track, trackEffect.Container); IComposition composition = group.AddComposition(); IEffect compositionEffect = composition.AddEffect(0, 10, def); Assert.AreSame(group, compositionEffect.Group); Assert.AreSame(composition, compositionEffect.Container); IClip clip = track.AddClip("..\\..\\image1.jpg", GroupMediaType.Image, InsertPosition.Absolute, 0, 0, 10); IEffect clipEffect = clip.AddEffect(0, 10, def); Assert.AreSame(group, clip.Group); Assert.AreSame(clip, clipEffect.Container); } }
public void JumpVolume() { // and audible demonstration of the difference between interpolating // parameter values for an effect, and jumping directly to them. string outputFile = "JumpVolume.wma"; using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); ITrack track = group.AddTrack(); IClip clip = track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Relative, 0, 0, 10); EffectDefinition effectDefinition = new EffectDefinition(DxtSubObjects.AudioMixer); Parameter volumeParameter = new Parameter("Vol", 0.0, 2, 1.0); volumeParameter.Intervals.Add(new Interval(IntervalMode.Jump, 2.5, "0.2")); volumeParameter.Intervals.Add(new Interval(IntervalMode.Jump, 3.5, "0.8")); volumeParameter.Intervals.Add(new Interval(IntervalMode.Jump, 4.5, "0.2")); volumeParameter.Intervals.Add(new Interval(IntervalMode.Jump, 5, "1.0")); volumeParameter.Intervals.Add(new Interval(IntervalMode.Interpolate, clip.Duration, "0.0")); effectDefinition.Parameters.Add(volumeParameter); clip.AddEffect(0, clip.Duration, effectDefinition); using ( IRenderer renderer = new WindowsMediaRenderer(timeline, outputFile, WindowsMediaProfiles.MediumQualityAudio)) { renderer.Render(); } } }
public void EnsureClipBubblesBeforeAndAfterEffectAddedUp() { int beforeCount = 0; int afterCount = 0; using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); ITrack track = group.AddTrack(); track.BeforeEffectAdded += new EventHandler(delegate { beforeCount++; }); track.AfterEffectAdded += new EventHandler <AfterEffectAddedEventArgs>(delegate { afterCount++; }); IClip clip = track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absoloute, 0, 0, -1); clip.AddEffect(0, 1, StandardEffects.CreateDefaultBlur()); Assert.AreEqual(1, beforeCount); Assert.AreEqual(1, afterCount); } }
public void AddEffectToClip() { bool beforeFired = false; bool afterFired = false; using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddVideoGroup(24, 64, 64); ITrack track = group.AddTrack(); IClip clip = track.AddClip("transitions.wmv", GroupMediaType.Video, InsertPosition.Absoloute, 0, 0, -1); clip.BeforeEffectAdded += new EventHandler(delegate { beforeFired = true; }); clip.AfterEffectAdded += new EventHandler <AfterEffectAddedEventArgs>(delegate { afterFired = true; }); EffectDefinition defintion = StandardEffects.CreateBlurEffect(2, clip.Duration, 20); IEffect effect = clip.AddEffect("blur", -1, 0, clip.Duration, defintion); Assert.IsTrue(beforeFired); Assert.IsTrue(afterFired); Assert.AreEqual("blur", effect.Name); Assert.AreEqual(0, effect.Priority); Assert.AreEqual(clip.Duration, effect.Duration); Assert.AreEqual(0, clip.Offset); Assert.AreSame(defintion, effect.EffectDefinition); PrepareToExecute(timeline, @"<timeline framerate=""30.0000000""> <group type=""video"" bitdepth=""24"" width=""64"" height=""64"" framerate=""30.0000000"" previewmode=""0""> <track> <clip start=""0"" stop=""7.9990000"" src=""transitions.wmv"" mstart=""0""> <effect start=""0"" stop=""7.9990000"" clsid=""{7312498D-E87A-11D1-81E0-0000F87557DB}"" username=""blur""> <param name=""PixelRadius"" value=""2""> <linear time=""7.9990000"" value=""20"" /> </param> </effect> </clip> </track> </group> </timeline>"); } }
public void WatermarkVideoClip() { // this demonstrates one way of watermarking a video clip... string outputFile = "WatermarkVideoClip.wmv"; using (ITimeline timeline = new DefaultTimeline(15)) { // greate our default audio track timeline.AddAudioGroup().AddTrack(); // add a video group, 32bpp, 320x240 (32bpp required to allow for an alpha channel) IGroup videoGroup = timeline.AddVideoGroup(32, 320, 240); // add our default video track ITrack videoTrack = videoGroup.AddTrack(); // add another video track, this will be used to contain our watermark image ITrack watermarkTrack = videoGroup.AddTrack(); // add the video in "transitions.wmv" to the first video track, and the audio in "transitions.wmv" // to the first audio track. timeline.AddVideoWithAudio("transitions.wmv"); // add the watermark image in, and apply it for the duration of the videoContent // this image will be stretched to fit the video clip, and in this case is a transparent gif. IClip watermarkClip = watermarkTrack.AddImage("testlogo.gif", 0, videoTrack.Duration); // add a alpha setter effect to the image, this will adjust the alpha of the image to be 0.5 // of it's previous value - so the watermark is 50% transparent. watermarkClip.AddEffect(0, watermarkClip.Duration, StandardEffects.CreateAlphaSetterRamp(0.8)); // add a transition to the watermark track, this allows the video clip to "shine through" the watermark, // base on the values present in the alpha channel of the watermark track. watermarkTrack.AddTransition(0, videoTrack.Duration, StandardTransitions.CreateKey(KeyTransitionType.Alpha, null, null, null, null, null), false); using ( // render it to windows media var renderer = new WindowsMediaRenderer(timeline, outputFile, WindowsMediaProfiles.HighQualityVideo)) { renderer.Render(); } } }