Same video was not generating in windows appl. with console appl. code

Feb 9, 2011 at 12:59 PM

Hi,

I have modified code from http://splicer.codeplex.com/SourceControl/changeset/changes/42100 link (Generating a video file from list of images with an audio file), to use it in windows form application. However the output was not same as it was generated with the code given in the above link. So, can anyone help me in to get correct output.

public partial class Form1 : Form
    {
        string[] SourceImage = {@"D:\Samples\WindowsImageToVideo\WindowsImageToVideo\WindowsImageToVideo\001.jpg",
                                @"D:\Samples\WindowsImageToVideo\WindowsImageToVideo\WindowsImageToVideo\002.jpg",
                                @"D:\Samples\WindowsImageToVideo\WindowsImageToVideo\WindowsImageToVideo\003.jpg"};
        string sourceTrackFile = @"D:\Samples\WindowsImageToVideo\WindowsImageToVideo\WindowsImageToVideo\ff404.wav";
        string outputFile = @"C:\Documents and Settings\sneelakanta\Desktop\test.avi";
       
        public Form1()
        {
            InitializeComponent();
        }

        private void RenderVideo()
        {
                using (ITimeline timeline = new DefaultTimeline())
                {
                    PopulateTimeline(timeline);
                    //IRenderer rend = (AbstractRenderer) new WindowsMediaRenderer(timeline, outputFile, WindowsMediaProfiles.HighQualityVideo);

                    // When i used WindowsMediaRenderer it was generated a video file but not playing

                    IRenderer renderer = new AviFileRenderer(timeline, outputFile);                   

                    // When i used AviFileRenderer it was generated a video file however generated video was not same as it was generated with the code given in the link.

                    rend.Render();
                }
        }

       private void PopulateTimeline(ITimeline timeline)
        {
            IGroup group = timeline.AddVideoGroup(32, 176, 144);
           
            ITrack audioTrack = timeline.AddAudioGroup().AddTrack();
            IClip audioClip = audioTrack.AddAudio(sourceTrackFile);

            ITrack videoTrack = group.AddTrack();

            double step = audioClip.Duration / SourceImage.Length;
            for (int i = 0; i < SourceImage.Length; i++)
            {
                videoTrack.AddImage(SourceImage[i], 0, step);
            }
        }

        private void RenderVideoUsingSplicer(IRenderer renderer)
        {
            try
            {
                renderer.Render();
            }
            finally
            {
                var disposable = renderer as IDisposable;
                if (disposable != null) disposable.Dispose();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            RenderVideo();
        }
   }

 

Thanks

Prasad