private static void CreateWatermark(ITrackContainer tracks, string imageName, double duration) { var videoTrack = tracks.AddTrack(); var clip = videoTrack.AddImage(imageName, 0, duration); clip.AddEffect(0, duration, StandardEffects.CreateAlphaSetterRamp(0.5)); videoTrack.AddTransition(0, duration, StandardTransitions.CreateKey(KeyTransitionType.Rgb, null, null, null, 0x00FFFFFF, null), false); }
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(); } } }
public void CreateAlphaSetterRampLowerThenZero() { StandardEffects.CreateAlphaSetterRamp(-1); }
public void CreateAlphaSetterRampAboveOne() { StandardEffects.CreateAlphaSetterRamp(2); }
public void CreateAlphaSetterRamp() { StandardEffects.CreateAlphaSetterRamp(0.5); }