public void CreateAudioEnvelopeWithFades()
 {
     StandardEffects.CreateAudioEnvelope(0.5, 1, 1, 5);
     StandardEffects.CreateAudioEnvelope(0.2, 0, 1, 5);
     StandardEffects.CreateAudioEnvelope(0.7, 1, 0, 5);
     StandardEffects.CreateAudioEnvelope(0.15, 0, 0, 5);
 }
        public void FadeBetweenImages()
        {
            // generates a little slide-show, with audio track and fades between images.

            string outputFile = "FadeBetweenImages.wmv";

            using (ITimeline timeline = new DefaultTimeline())
            {
                IGroup group = timeline.AddVideoGroup(32, 160, 100);

                ITrack videoTrack = group.AddTrack();
                IClip  clip1      = videoTrack.AddImage("image1.jpg", 0, 2); // play first image for a little while
                IClip  clip2      = videoTrack.AddImage("image2.jpg", 0, 2); // and the next
                IClip  clip3      = videoTrack.AddImage("image3.jpg", 0, 2); // and finally the last
                IClip  clip4      = videoTrack.AddImage("image4.jpg", 0, 2); // and finally the last

                double halfDuration = 0.5;

                // fade out and back in
                group.AddTransition(clip2.Offset - halfDuration, halfDuration, StandardTransitions.CreateFade(), true);
                group.AddTransition(clip2.Offset, halfDuration, StandardTransitions.CreateFade(), false);

                // again
                group.AddTransition(clip3.Offset - halfDuration, halfDuration, StandardTransitions.CreateFade(), true);
                group.AddTransition(clip3.Offset, halfDuration, StandardTransitions.CreateFade(), false);

                // and again
                group.AddTransition(clip4.Offset - halfDuration, halfDuration, StandardTransitions.CreateFade(), true);
                group.AddTransition(clip4.Offset, halfDuration, StandardTransitions.CreateFade(), false);

                // add some audio
                ITrack audioTrack = timeline.AddAudioGroup().AddTrack();

                IClip audio =
                    audioTrack.AddAudio("testinput.wav", 0, videoTrack.Duration);

                // create an audio envelope effect, this will:
                // fade the audio from 0% to 100% in 1 second.
                // play at full volume until 1 second before the end of the track
                // fade back out to 0% volume
                audioTrack.AddEffect(0, audio.Duration,
                                     StandardEffects.CreateAudioEnvelope(1.0, 1.0, 1.0, audio.Duration));

                // render our slideshow out to a windows media file
                using (
                    IRenderer renderer =
                        new WindowsMediaRenderer(timeline, outputFile, WindowsMediaProfiles.HighQualityVideo))
                {
                    renderer.Render();
                }
            }
        }
示例#3
0
        /// <summary>
        /// Adds the sound files in a random order
        /// </summary>
        /// <param name="tracks">The track container that will hold the new track</param>
        /// <param name="soundFiles">The list of sound files to add</param>
        /// <param name="duration"></param>
        /// <returns>The new track</returns>
        private ITrack AddBackgroundMusic(ITrackContainer tracks, IList <string> soundFiles, double duration)
        {
            var audioTrack = tracks.AddTrack();

            if (soundFiles.Any())
            {
                var shuffled = shuffler.Shuffle(soundFiles);
                foreach (var soundFile in shuffled)
                {
                    audioTrack.AddAudio(soundFile, 0, duration);
                }
                audioTrack.AddEffect(0, audioTrack.Duration, StandardEffects.CreateAudioEnvelope(0.05));
            }

            return(audioTrack);
        }
示例#4
0
        static void Main(string[] args)
        {
            string folderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Pics");

            using (ITimeline timeline = new DefaultTimeline(30))
            {
                double halfDuration = 1;
                IGroup group        = timeline.AddVideoGroup("video", 30, 32, 1920, 1080);

                ITrack        videoTrack = group.AddTrack();
                List <string> filePaths  = Directory.EnumerateFiles(folderPath, "*.jpg").ToList();
                for (int i = 0; i < filePaths.Count; i++)
                {
                    IClip clip = videoTrack.AddImage(filePaths[i], 0, 10);
                    if (i > 0)
                    {
                        group.AddTransition(clip.Offset - halfDuration, halfDuration, StandardTransitions.CreateFade(), true);
                        group.AddTransition(clip.Offset, halfDuration, StandardTransitions.CreateFade(), false);
                    }
                }

                string folderPath2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Audio");
                string audioPath   = Directory.EnumerateFiles(folderPath2, "*.wav").FirstOrDefault(x => x != null);

                ITrack audioTrack = timeline.AddAudioGroup().AddTrack();

                IClip audio = audioTrack.AddAudio(audioPath, 0, videoTrack.Duration);

                audioTrack.AddEffect(0, audio.Duration, StandardEffects.CreateAudioEnvelope(1.0, 1.0, 1.0, audio.Duration));

                using (var renderer = new WindowsMediaRenderer(timeline, "output.wmv", WindowsMediaProfiles.FullHD))
                {
                    renderer.Render();
                }
            }

            Console.WriteLine("Hello World!");
        }
 public void CreateAudioEnvelopeVolumeTooLow2()
 {
     StandardEffects.CreateAudioEnvelope(-1);
 }
 public void CreateAudioEnvelopeVolumeTooHigh2()
 {
     StandardEffects.CreateAudioEnvelope(2, 1, 1, 5);
 }
 public void CreateAudioEnvelope()
 {
     StandardEffects.CreateAudioEnvelope(0.5);
 }
 public void CreateAudioEnvelopeWithInvalidFadeDurations()
 {
     StandardEffects.CreateAudioEnvelope(0.5, 4, 4, 2);
 }