Пример #1
0
        static void DoWork(object data)
        {
            int index = (int)data;

            try
            {
                Console.WriteLine("Thread {0} started...", index);

                // Create BytescoutImageToVideo.ImageToVideo object instance
                ImageToVideo converter = new ImageToVideo();

                // Activate the component
                converter.RegistrationName = "demo";
                converter.RegistrationKey  = "demo";

                // Add images and set the duration for every slide
                Slide slide;
                slide           = converter.AddImageFromFileName("..\\..\\..\\..\\slide1.jpg");
                slide.Duration  = 3000;                // 3000ms = 3s
                slide.InEffect  = GetRandomEffect();
                slide.OutEffect = GetRandomEffect();


                slide           = converter.AddImageFromFileName("..\\..\\..\\..\\slide2.jpg");
                slide.Duration  = 3000;
                slide.InEffect  = GetRandomEffect();
                slide.OutEffect = GetRandomEffect();

                slide           = converter.AddImageFromFileName("..\\..\\..\\..\\slide3.jpg");
                slide.Duration  = 3000;
                slide.InEffect  = GetRandomEffect();
                slide.OutEffect = GetRandomEffect();


                // Set output video size
                converter.OutputWidth  = 640;
                converter.OutputHeight = 480;

                // Set output video file name
                converter.OutputVideoFileName = String.Format("result_{0}.wmv", index);

                // Run the conversion
                converter.RunAndWait();

                // Release resources
                System.Runtime.InteropServices.Marshal.ReleaseComObject(converter);

                Console.WriteLine("Thread {0} finished.", index);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Thread {0} failed: {1}", index, ex.Message);
            }

            // check until numBusy is equal to 0 (as it we use it as a counter to count finished threads)
            if (Interlocked.Decrement(ref numBusy) == 0)
            {
                doneEvent.Set();
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Converting JPG slides to video, please wait...");

                // Create BytescoutImageToVideoLib.ImageToVideo object instance
                ImageToVideo converter = new ImageToVideo();

                // Activate the component
                converter.RegistrationName = "demo";
                converter.RegistrationKey  = "demo";

                // Add images from memory and set the duration for every slide:

                Slide  slide;
                byte[] bytes;

                bytes          = System.IO.File.ReadAllBytes("..\\..\\..\\..\\slide1.jpg");
                slide          = converter.AddImageFromBuffer(bytes);
                slide.Duration = 3000;

                bytes          = System.IO.File.ReadAllBytes("..\\..\\..\\..\\slide3.jpg");
                slide          = converter.AddImageFromBuffer(bytes);
                slide.Duration = 3000;

                bytes          = System.IO.File.ReadAllBytes("..\\..\\..\\..\\slide3.jpg");
                slide          = converter.AddImageFromBuffer(bytes);
                slide.Duration = 3000;

                // Set output video size
                converter.OutputWidth  = 640;
                converter.OutputHeight = 480;

                // Set output video file name
                converter.OutputVideoFileName = "result.wmv";

                // Run the conversion
                converter.RunAndWait();

                // Release resources
                System.Runtime.InteropServices.Marshal.ReleaseComObject(converter);
                converter = null;

                Console.WriteLine("Done. Press any key to continue..");
                Console.ReadKey();

                // Open the result video file in default media player
                Process.Start("result.wmv");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.ToString());
                Console.WriteLine("\nPress any key to exit");
                Console.ReadKey();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // These test files will be copied to the project directory on the pre-build event (see the project properties).
            String file1 = Server.MapPath("bin\\slide1.jpg");
            String file2 = Server.MapPath("bin\\slide2.jpg");
            String file3 = Server.MapPath("bin\\slide3.jpg");

            String outputVideoFile = Path.GetTempPath() + "result.wmv";

            // Create BytescoutImageToVideoLib.ImageToVideo object instance
            ImageToVideo converter = new ImageToVideo();

            // Activate the component
            converter.RegistrationName = "demo";
            converter.RegistrationKey  = "demo";

            // Add images and set the duration for every slide
            Slide slide = converter.AddImageFromFileName(file1);

            slide.Duration = 3000;             // 3000ms = 3s
            slide          = converter.AddImageFromFileName(file2);
            slide.Duration = 3000;
            slide          = converter.AddImageFromFileName(file3);
            slide.Duration = 3000;

            // Set output video size
            converter.OutputWidth  = 400;
            converter.OutputHeight = 300;

            // Set output video file name
            converter.OutputVideoFileName = outputVideoFile;

            // Run the conversion
            converter.RunAndWait();

            // Release resources
            System.Runtime.InteropServices.Marshal.ReleaseComObject(converter);
            converter = null;


            // Show filename of result file

            Response.Clear();
            Response.ContentType = "text/html";

            if (File.Exists(outputVideoFile))
            {
                Response.Write("Result video file:  <b>" + outputVideoFile + "</b>");
            }
            else
            {
                Response.Write("Conversion failed. Error information: " + converter.LastError);
            }

            Response.End();
        }
Пример #4
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Converting JPG slides to video, please wait...");

                // Create BytescoutImageToVideoLib.ImageToVideo object instance
                ImageToVideo converter = new ImageToVideo();

                // Activate the component
                converter.RegistrationName = "demo";
                converter.RegistrationKey  = "demo";

                // Enable transition effects for the first and last slide
                converter.UseInEffectForFirstSlide = true;
                converter.UseOutEffectForLastSlide = true;

                // Add images and set slide durations and transition effects
                Slide slide;
                slide           = converter.AddImageFromFileName("..\\..\\..\\..\\slide1.jpg");
                slide.InEffect  = TransitionEffectType.teFade;
                slide.OutEffect = TransitionEffectType.teFade;
                slide.Duration  = 3000;                // 3000ms = 3s
                slide           = converter.AddImageFromFileName("..\\..\\..\\..\\slide2.jpg");
                slide.Duration  = 3000;
                slide.InEffect  = TransitionEffectType.teWipeLeft;
                slide.OutEffect = TransitionEffectType.teWipeRight;
                slide           = converter.AddImageFromFileName("..\\..\\..\\..\\slide3.jpg");
                slide.Duration  = 3000;
                slide.InEffect  = TransitionEffectType.teWipeLeft;
                slide.OutEffect = TransitionEffectType.teWipeRight;

                // Set output video size
                converter.OutputWidth  = 640;
                converter.OutputHeight = 480;

                // Set output video file name
                converter.OutputVideoFileName = "result.webm";

                // Run the conversion
                converter.RunAndWait();

                // Open the result video file in default webm player
                Process.Start("result.webm");

                Console.WriteLine("Done. Press any key to continue...");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.ToString());
                Console.WriteLine("\nPress any key to exit.");
                Console.ReadKey();
            }
        }
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Converting JPG slides to video, please wait...");

                // Create BytescoutImageToVideoLib.ImageToVideo object instance
                ImageToVideo converter = new ImageToVideo();

                Color CC = new Color();
                CC = Color.Transparent;

                // Activate the component
                converter.RegistrationName = "demo";
                converter.RegistrationKey  = "demo";

                // Set movie background color
                converter.SetBackgroundColorRGB(0, 255, 128);

                // Add images and set slide durations
                Slide slide;
                slide          = converter.AddImageFromFileName("..\\..\\..\\..\\slide1.jpg");
                slide.Duration = 3000;                 // 3000ms = 3s
                slide          = converter.AddImageFromFileName("..\\..\\..\\..\\slide2.jpg");
                slide.Duration = 3000;
                slide          = converter.AddImageFromFileName("..\\..\\..\\..\\slide3.jpg");
                slide.Duration = 3000;

                // Set output video size
                converter.OutputWidth  = 640;
                converter.OutputHeight = 480;

                // Set output video file name
                converter.OutputVideoFileName = "result.wmv";

                // Run the conversion
                converter.RunAndWait();

                // Release resources
                System.Runtime.InteropServices.Marshal.ReleaseComObject(converter);

                // Open the result video file in default media player
                Process.Start("result.wmv");

                Console.WriteLine("Done. Press any key to continue...");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.ToString());
                Console.WriteLine("\nPress any key to exit.");
                Console.ReadKey();
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Converting JPG slides to video, please wait...");

                // Create BytescoutImageToVideoLib.ImageToVideo object instance
                ImageToVideo converter = new ImageToVideo();

                // Activate the component
                converter.RegistrationName = "demo";
                converter.RegistrationKey  = "demo";

                // Add images and set slide durations and effects
                Slide slide;
                slide               = converter.AddImageFromFileName("..\\..\\..\\..\\slide1.jpg");
                slide.Duration      = 3000;                         // 3000ms = 3s
                slide.VisualEffect  = VisualEffectType.veGrayscale; // make the slide grayscale
                slide               = converter.AddImageFromFileName("..\\..\\..\\..\\slide2.jpg");
                slide.Duration      = 3000;
                slide.VisualEffect  = VisualEffectType.veSepia;                // make the slide sepia
                slide               = converter.AddImageFromFileName("..\\..\\..\\..\\slide3.jpg");
                slide.Duration      = 3000;
                slide.RotationAngle = RotationAngle.raRotate90;                 // rotate the slide 90 degrees.

                // Set output video size
                converter.OutputWidth  = 640;
                converter.OutputHeight = 480;

                // Set output video file name
                converter.OutputVideoFileName = "result.wmv";

                // Run the conversion
                converter.RunAndWait();

                // Release resources
                System.Runtime.InteropServices.Marshal.ReleaseComObject(converter);

                // Open the result video file in default media player
                Process.Start("result.wmv");

                Console.WriteLine("Done. Press any key to continue..");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.ToString());
                Console.WriteLine("\nPress any key to exit.");
                Console.ReadKey();
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Converting JPG slides to video, please wait...");

                // Create ImageToVideo object instance
                ImageToVideo converter = new ImageToVideo();

                // Activate the component
                converter.RegistrationName = "demo";
                converter.RegistrationKey  = "demo";

                // Add images and set the duration for every slide
                Slide slide;
                slide          = converter.AddImageFromFileName("slide1.jpg");
                slide.Duration = 3000; // 3000ms = 3s
                slide          = converter.AddImageFromFileName("slide2.jpg");
                slide.Duration = 3000;
                slide          = converter.AddImageFromFileName("slide3.jpg");
                slide.Duration = 3000;

                // Set output video size
                converter.OutputWidth  = 640;
                converter.OutputHeight = 480;

                // Set output video file name
                converter.OutputVideoFileName = "result.wmv";

                // Run the conversion
                converter.RunAndWait();

                // Release resources
                System.Runtime.InteropServices.Marshal.ReleaseComObject(converter);

                // Open the result video file in default media player
                Process.Start("result.wmv");

                Console.WriteLine("Done. Press any key to continue..");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
                Console.WriteLine();
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
        }
Пример #8
0
        static void DoWork(object data)
        {
            ThreadData threadData = (ThreadData)data;

            try
            {
                // Create BytescoutImageToVideoLib.ImageToVideo object instance
                ImageToVideo converter = new ImageToVideo();

                // Activate the component
                converter.RegistrationName = "demo";
                converter.RegistrationKey  = "demo";

                // Add slides
                foreach (string file in threadData.InputFiles)
                {
                    Slide slide = converter.AddImageFromFileName(file);
                    slide.Duration = 3000;                     // 3000ms = 3s
                    slide.Effect   = SlideEffectType.seEaseIn;
                }

                // Set output video size
                converter.OutputWidth  = 640;
                converter.OutputHeight = 480;

                // Set output video file name
                converter.OutputVideoFileName = threadData.OutputFile;

                // Run the conversion
                converter.RunAndWait();

                // Release resources
                Marshal.ReleaseComObject(converter);

                Console.WriteLine("Thread finished.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            if (Interlocked.Decrement(ref _numBusy) == 0)
            {
                _doneEvent.Set();
            }
        }
Пример #9
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Converting JPG slides to video, please wait...");

                // Create BytescoutImageToVideoLib.ImageToVideo object instance
                ImageToVideo converter = new ImageToVideo();

                // Activate the component
                converter.RegistrationName = "demo";
                converter.RegistrationKey  = "demo";


                // set input video file
                converter.InputVideoFileName = "..\\..\\..\\..\\input.wmv";

                // set input audio file
                converter.ExternalAudioTrackFromFileName = "..\\..\\..\\..\\11k16bitpcm.wav";

                // Set output video file name
                converter.OutputVideoFileName = "ReplacedAudio.wmv";

                // Run the conversion
                converter.RunAndWait();

                // Release resources
                System.Runtime.InteropServices.Marshal.ReleaseComObject(converter);

                // Open the result video file in default media player
                Process.Start("ReplacedAudio.wmv");

                Console.WriteLine("Done. Press any key to continue...");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.ToString());
                Console.WriteLine("\nPress any key to exit.");
                Console.ReadKey();
            }
        }
Пример #10
0
        static void ThreadProc2(object state)
        {
            ManualResetEvent event2 = (ManualResetEvent)state;

            try
            {
                ImageToVideo converter = new ImageToVideo();
                converter.RegistrationName = "demo";
                converter.RegistrationKey  = "demo";

                Array x = Enum.GetValues(typeof(PanZoomEffectType));

                foreach (string file in Directory.GetFiles(@".\images"))
                {
                    Slide slide = converter.AddImageFromFileName(file);
                    slide.Duration          = 3000;
                    slide.PanZoomEffect     = (PanZoomEffectType)x.GetValue((new Random()).Next(8));
                    slide.InEffect          = TransitionEffectType.teFade;
                    slide.InEffectDuration  = 250;
                    slide.OutEffect         = TransitionEffectType.teFade;
                    slide.OutEffectDuration = 250;
                }

                converter.OutputVideoFileName = "result2.wmv";
                converter.OutputWidth         = 640;
                converter.OutputHeight        = 480;
                converter.RunAndWait();

                System.Runtime.InteropServices.Marshal.ReleaseComObject(converter);

                Console.WriteLine("Second thread finished.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.ToString());
            }
            finally
            {
                event2.Set();
            }
        }
Пример #11
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Converting JPG slides to video, please wait...");

                for (int i = 0; i < 5; i++)
                {
                    // Create BytescoutImageToVideoLib.ImageToVideo object instance
                    ImageToVideo converter = new ImageToVideo();

                    // Activate the component
                    converter.RegistrationName = "demo";
                    converter.RegistrationKey  = "demo";

                    // Set output video size
                    converter.OutputWidth  = 640;
                    converter.OutputHeight = 480;

                    // Add images and set duration and effects for every slide
                    Slide slide;
                    slide           = converter.AddImageFromFileName("..\\..\\..\\..\\slide1.jpg");
                    slide.Duration  = 3000;                    // 3000ms = 3s
                    slide.InEffect  = TransitionEffectType.teFade;
                    slide.OutEffect = TransitionEffectType.teFade;
                    Release(slide);                     // useful to decrease memory consumption during the batch conversion but not critical

                    slide           = converter.AddImageFromFileName("..\\..\\..\\..\\slide2.jpg");
                    slide.Duration  = 3000;
                    slide.InEffect  = TransitionEffectType.teWipeLeft;
                    slide.OutEffect = TransitionEffectType.teWipeRight;
                    Release(slide);

                    slide           = converter.AddImageFromFileName("..\\..\\..\\..\\slide3.jpg");
                    slide.Duration  = 3000;
                    slide.InEffect  = TransitionEffectType.teWipeLeft;
                    slide.OutEffect = TransitionEffectType.teWipeRight;
                    Release(slide);

                    // Set output video file name
                    converter.OutputVideoFileName = "result" + i + ".wmv";

                    // Run the conversion
                    converter.RunAndWait();

                    Console.WriteLine("Created " + converter.OutputVideoFileName);

                    // CRITICAL!
                    // Releases all resources consumed during the conversion
                    Release(converter);
                }

                Console.WriteLine("Done. Press any key to continue..");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.ToString());
                Console.WriteLine("\nPress any key to exit");
                Console.ReadKey();
            }
        }
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Converting JPG slides to video with 70 advanced 3D effects variations, please wait...");

                // Create BytescoutImageToVideoLib.ImageToVideo object instance
                ImageToVideo converter = new ImageToVideo();

                // Activate the component
                converter.RegistrationName = "demo";
                converter.RegistrationKey  = "demo";

                // Enable transition effects for the first first slide
                converter.UseInEffectForFirstSlide = true;

                converter.Slides.DefaultSlideDuration       = 1000;
                converter.Slides.DefaultSlideEffectDuration = 500;

                bool bChangeSlide = true; // temporary variable to change slides


                // now try all 70 advanced 3D transition effects from 70 to 140
                for (int i = 67; i < 140; i++)
                {
                    // Add slide image, set the duration

                    Slide slide = null;

                    if (!bChangeSlide)
                    {
                        slide = converter.AddImageFromFileName("..\\..\\..\\..\\slide1.jpg");
                    }
                    else
                    {
                        slide = converter.AddImageFromFileName("..\\..\\..\\..\\slide2.jpg");
                    }

                    bChangeSlide = !bChangeSlide;             // switch to use another slide next tim

                    slide.InEffect = (TransitionEffectType)i; // effect index
                }


                // Set output video size
                converter.OutputWidth  = 320;
                converter.OutputHeight = 240;

                // Set output video file name
                converter.OutputVideoFileName = "result.wmv";

                // Run the conversion
                converter.RunAndWait();

                // Release resources
                System.Runtime.InteropServices.Marshal.ReleaseComObject(converter);
                converter = null;


                // Open the result video file in default media player
                Process.Start("result.wmv");

                Console.WriteLine("Done. Press any key to continue...");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.ToString());
                Console.WriteLine("\nPress any key to exit.");
                Console.ReadKey();
            }
        }
        private static bool createTmpGifImage(string kw)
        {
            /*DirectoryInfo directory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "uploads\\" + kw);
             * Random rnd1 = new Random();
             * AnimatedGifEncoder e = new AnimatedGifEncoder();
             *
             *
             * e.Start(AppDomain.CurrentDomain.BaseDirectory + "\\uploads\\tmp.gif");
             *
             * e.SetRepeat(0);
             * e.SetDelay(1000);
             * e.SetSize(640, 480);
             * foreach (System.IO.FileInfo file in directory.GetFiles())
             * {
             *  Console.WriteLine(file.Name);
             *  Image newImage = ScaleImage(Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "uploads\\" + kw + "\\" + file.Name), 640, 480); //Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "uploads\\" + kw + "\\" + file.Name);
             *  e.AddFrame(newImage);
             * }
             *
             *
             *
             *
             * e.Finish();
             * if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\uploads\\tmp.gif")) { return true; }*/

            Console.Write("Converting JPG slides into video, please wait..");

// Create BytescoutImageToVideoLib.ImageToVideo object instance
            ImageToVideo converter = new ImageToVideo();

// Activate the component
            converter.RegistrationName = "demo";
            converter.RegistrationKey  = "demo";

// Add images and set the duration for every slide
            Slide         slide;
            DirectoryInfo directory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "uploads\\" + kw);

            foreach (System.IO.FileInfo file in directory.GetFiles())
            {
                try
                {
                    slide          = (Slide)converter.AddImageFromFileName(AppDomain.CurrentDomain.BaseDirectory + "uploads\\" + kw + "\\" + file.Name);
                    slide.Duration = 3000; // 3000ms = 3s
                }
                catch (Exception ex)
                {
                    //
                }
            }

/*slide = (Slide) converter.AddImageFromFileName("..\\..\\..\\..\\slide1.jpg");
 * slide.Duration = 3000; // 3000ms = 3s
 *
 * slide = (Slide) converter.AddImageFromFileName("..\\..\\..\\..\\slide2.jpg");
 * slide.Duration = 3000;
 *
 * slide = (Slide) converter.AddImageFromFileName("..\\..\\..\\..\\slide3.jpg");
 * slide.Duration = 3000;*/



// Set output video size
            converter.OutputWidth = 640;

            converter.OutputHeight = 480;

// Set output video file name
            converter.OutputVideoFileName = AppDomain.CurrentDomain.BaseDirectory + "video/" + FirstUpper(kw) + ".wmv";

// Run the conversion
            converter.RunAndWait();

            Console.WriteLine("Conversion is done. Press any key to continue..");

//Console.ReadKey();

// Open the result video file in default media player
//Process.Start(AppDomain.CurrentDomain.BaseDirectory + "video/" + FirstUpper(kw) + ".wmv");

            return(true);
        }