Exemplo n.º 1
0
        public void GenerateSnapshot(string inputFile, string outputFile, string objectID, int snapshotAfterSec)
        {
            _4screen.CSB.DataAccess.Business.MonitoringLog monLog = new MonitoringLog();                        // #0.5.2.0

            try
            {
                Turbine.TVE3 tve = new Turbine.TVE3();

                // set license keys:
                tve.Key1 = 198021903;
                tve.Key2 = 1582164514;

                tve.InfoOpen(inputFile);
                tve.InfoSaveInputFrame(snapshotAfterSec, outputFile, 90);
                int intDuration = (int)(tve.InfoGet("totalDurationMs") / 1000d);

                WriteMonitoringLog("", objectID, "", 7, "generate image snapshot (Step 7 / 14)", _4screen.CSB.Common.MonitoringLogState.OK, "");
            }
            catch (System.Exception ex)
            {
                WriteMonitoringLog("", objectID, "", 7, "generate image snapshot (Step 7 / 14)", _4screen.CSB.Common.MonitoringLogState.OKWithWarning, ex.Message);
            }
            finally
            {
                try
                {
                    tve.Dispose();
                    if (tve != null)
                    {
                        tve = null;
                    }
                }
                catch { }
            }
        }
Exemplo n.º 2
0
        public void EncodeNextVideo(VideoEncoderQueue videoEnc)
        {
            Video video = null;

            try
            {
                video = new Video(videoEnc.VideoID);

                DateTime Start = DateTime.Now;

                Console.WriteLine("Begin encoding");
                string UserDirectory = @"\\www\user\";
                //string UserDirectory = @"d:\Source3\Web\user\";

                string InputFileName     = UserDirectory + videoEnc.VideoInputFile;
                string OutputFileName    = UserDirectory + videoEnc.VideoOutputFile;
                string ThumbnailLocation = UserDirectory + videoEnc.ThumbnailOutputFile;

                Turbine.TVE3 tve = new Turbine.TVE3();

                // set license keys:
                tve.Key1 = 215362640;
                tve.Key2 = 1596049317;

                // load the base preset settings:
                tve.LoadSettings(@"c:\presets\300K_Broadband.settings");

                tve.VideoMethod = "VBR2";

                tve.VideoBitRate = 300000;
                // set output type (flv or swf) and output location:
                tve.OutputFormat = "fla";
                tve.SetOutputFile(OutputFileName);

                // encode source synchronously:
                tve.EncodeAsync(InputFileName);

                DateTime encStart   = DateTime.Now;
                bool     EncodeOKAY = true;
                while (tve.EncodeAsyncIsEncoding && EncodeOKAY)
                {
                    Console.WriteLine(tve.EncodeAsyncPercentage.ToString() + "% Complete");
                    Application.DoEvents();

                    if (encStart > DateTime.Now.AddMinutes(1) && tve.EncodeAsyncPercentage == 1)
                    {
                        EncodeOKAY = false;
                    }
                    Thread.Sleep(300);
                }

                // done - flush encoding:
                tve.EncodeFlush();

                tve.InfoOpen(InputFileName);

                decimal Duration = 0.0M;

                try
                {
                    int DurationMS = (int)tve.InfoGet("totalDurationMs");

                    TimeSpan DurationSpan = new TimeSpan(0, 0, 0, 0, DurationMS);

                    Duration = decimal.Parse(DurationSpan.Minutes + "." + DurationSpan.Seconds);
                }
                catch { }

                tve.InfoSaveInputFrame(2000, ThumbnailLocation, 100);

                Photo.ResizeTo124x91(videoEnc.ThumbnailOutputFile);

                // open video again to make sure no changes have been missed
                video = new Video(videoEnc.VideoID);

                if (EncodeOKAY)
                {
                    videoEnc.Status = (int)VideoEncoderStatus.Completed;

                    video.Status = (int)VideoStatus.Active;
                }
                else
                {
                    videoEnc.Status = (int)VideoEncoderStatus.Errored;
                    videoEnc.Error  = "Encoder Stalled";
                    video.Status    = (int)VideoStatus.EncoderError;
                }

                video.Duration = Convert.ToDecimal(Duration);

                DateTime End          = DateTime.Now;
                TimeSpan EncodingTime = End - Start;

                Console.WriteLine("Successfully encoded " + Duration.ToString() + " in " + EncodingTime.ToString());

                tve.Dispose();

                videoEnc.Save();
                video.Save();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                videoEnc.Status = (int)VideoEncoderStatus.Errored;
                videoEnc.Error  = ex.ToString();


                videoEnc.Save();

                if (video != null)
                {
                    video.Status = (int)VideoStatus.EncoderError;
                    video.Save();
                }
            }
            finally
            {
            }


            Console.WriteLine("Finished Encoding");
        }
Exemplo n.º 3
0
        public void EncodeNextVideo(VideoEncoderQueue videoEnc)
        {
            Video video = null;

            try
            {
                video = new Video(videoEnc.VideoID);

                DateTime Start = DateTime.Now;

                Console.WriteLine("Begin encoding");
                string UserDirectory = @"\\www\user\";
                //string UserDirectory = @"d:\Source3\Web\user\";

                string InputFileName = UserDirectory + videoEnc.VideoInputFile;
                string OutputFileName = UserDirectory + videoEnc.VideoOutputFile;
                string ThumbnailLocation = UserDirectory + videoEnc.ThumbnailOutputFile;

                Turbine.TVE3 tve = new Turbine.TVE3();

                // set license keys:
                tve.Key1 = 215362640;
                tve.Key2 = 1596049317;

                // load the base preset settings:
                tve.LoadSettings(@"c:\presets\300K_Broadband.settings");

                tve.VideoMethod = "VBR2";

                tve.VideoBitRate = 300000;
                // set output type (flv or swf) and output location:
                tve.OutputFormat = "fla";
                tve.SetOutputFile(OutputFileName);

                // encode source synchronously:
                tve.EncodeAsync(InputFileName);

                DateTime encStart = DateTime.Now;
                bool EncodeOKAY = true;
                while (tve.EncodeAsyncIsEncoding && EncodeOKAY)
                {
                    Console.WriteLine(tve.EncodeAsyncPercentage.ToString() + "% Complete");
                    Application.DoEvents();

                    if (encStart > DateTime.Now.AddMinutes(1) && tve.EncodeAsyncPercentage == 1)
                    {
                        EncodeOKAY = false;
                    }
                    Thread.Sleep(300);
                }

                // done - flush encoding:
                tve.EncodeFlush();

                tve.InfoOpen(InputFileName);

                decimal Duration = 0.0M;

                try
                {
                    int DurationMS = (int)tve.InfoGet("totalDurationMs");

                    TimeSpan DurationSpan = new TimeSpan(0, 0, 0, 0, DurationMS);

                    Duration = decimal.Parse(DurationSpan.Minutes + "." + DurationSpan.Seconds);
                }
                catch { }

                tve.InfoSaveInputFrame(2000, ThumbnailLocation, 100);

                Photo.ResizeTo124x91(videoEnc.ThumbnailOutputFile);

                // open video again to make sure no changes have been missed
                video = new Video(videoEnc.VideoID);

                if (EncodeOKAY)
                {
                    videoEnc.Status = (int)VideoEncoderStatus.Completed;

                    video.Status = (int)VideoStatus.Active;
                }
                else
                {

                    videoEnc.Status = (int)VideoEncoderStatus.Errored;
                    videoEnc.Error = "Encoder Stalled";
                    video.Status = (int)VideoStatus.EncoderError;
                }

                video.Duration = Convert.ToDecimal(Duration);

                DateTime End = DateTime.Now;
                TimeSpan EncodingTime = End - Start;

                Console.WriteLine("Successfully encoded " + Duration.ToString() + " in " + EncodingTime.ToString());

                tve.Dispose();

                videoEnc.Save();
                video.Save();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                videoEnc.Status = (int)VideoEncoderStatus.Errored;
                videoEnc.Error = ex.ToString();


                videoEnc.Save();

                if (video != null)
                {
                    video.Status = (int)VideoStatus.EncoderError;
                    video.Save();
                }
            }
            finally
            {

            }


            Console.WriteLine("Finished Encoding");

        }