private static void HandleLogEntry(Logger.LogEntry entry)
 {
     if (Debugger.IsAttached)
     {
         Debug.WriteLine(entry.ToString());
     }
 }
Пример #2
0
 private static void HandleLogEntry(Logger.LogEntry entry)
 {
     // we're just going to echo the logs to the debug output pane in the VS IDE, but you could append them to a file or re-route them into whatever log system you use
     if (Debugger.IsAttached)
     {
         Debug.WriteLine(entry.ToString());
     }
 }
Пример #3
0
 private static void HandleLogEntry(Logger.LogEntry entry)
 {
     // write log message to debug output window in VS
     if (Debugger.IsAttached)
     {
         Debug.WriteLine(entry.ToString());
     }
 }
Пример #4
0
        /// <summary>
        /// Encode a short YV12 AVI sequence to MPEG2.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public int Encode( DataSet data )
        {
            // Attach to requirement
            DataRow settings = data.Tables[0].Rows[0];

            // Load global check
            bool unattended = (bool) settings["Unattended"];

            // With logging
            using (Logger pLog = new Logger())
                try
                {
                    // Load all settings
                    bool bProgressive = (bool) settings["IsProgressive"];
                    bool bTopFirst = (bool) settings["IsTopFieldFirst"];
                    string sOutput = (string) settings["ResultMPGFile"];
                    short dFrameRate = (short) settings["FrameRate"];
                    short eFormat = (short) settings["VideoFormat"];
                    short lAspect = (short) settings["AspectRatio"];
                    int lVBVBuffer = (int) settings["VBVBuffer"];
                    string sInput = (string) settings["AVIFile"];
                    short lHeight = (short) settings["Height"];
                    long lBitRate = (long) settings["BitRate"];
                    bool bMEPG2 = (bool) settings["IsMpeg2"];
                    short lWidth = (short) settings["Width"];

                    // Load settings
                    Settings configuration = new Settings();

                    // Read the directory
                    string exePath = configuration.Directory;

                    // Try to default it
                    if (string.IsNullOrEmpty( exePath ))
                    {
                        // Try this
                        exePath = TestDirectory( "." );

                        // Try relative
                        if (null == exePath)
                            exePath = TestDirectory( @"..\..\External Tools" );
                    }

                    // Overwrite
                    CommandLineTool.PresetDirectory = exePath;

                    // Create the executer
                    using (YV122M2V pEncoder = new YV122M2V())
                    {
                        // Special HDTV correction
                        if (1080 == lHeight)
                            lHeight = 1088;

                        // Configure
                        pEncoder.VideoNorm = GetVideoNorm( eFormat );
                        pEncoder.AspectRatio = GetAspect( lAspect );
                        pEncoder.HiResMode = (lHeight >= 720);
                        pEncoder.FrameRateCode = dFrameRate;
                        pEncoder.OutputFile = sOutput;
                        pEncoder.InputFile = sInput;
                        pEncoder.Height = lHeight;
                        pEncoder.Width = lWidth;

                        // Use special path for high res mode
                        if (pEncoder.HiResMode)
                        {
                            // Test for diretory
                            DirectoryInfo hiRes = new DirectoryInfo( Path.Combine( CommandLineTool.PresetDirectory, "HDTV" ) );

                            // Use if it exists
                            if (hiRes.Exists)
                                CommandLineTool.PresetDirectory = hiRes.FullName;
                        }

                        // Check mode
                        if (bMEPG2)
                        {
                            // DVD/SVCD
                            pEncoder.Interlacing = bProgressive ? YV122M2V.InterlacingMode.None : (bTopFirst ? YV122M2V.InterlacingMode.TopFirst : YV122M2V.InterlacingMode.BottomFirst);
                            pEncoder.Format = MPEG2Enc.Formats.DVD;
                            pEncoder.BitRate = (int) (lBitRate / 1000);
                            pEncoder.BufferSize = (lVBVBuffer / 1024);
                        }
                        else
                        {
                            // VCD
                            pEncoder.Interlacing = YV122M2V.InterlacingMode.None;
                            pEncoder.Format = MPEG2Enc.Formats.VCD;
                        }

                        // Attach logger
                        pEncoder.OnError += pLog.ReportError;

                        // Start it
                        Stream pIn = pEncoder.Start();

                        // In erroror
                        if (null == pIn)
                            throw new Exception( StringResources.Strings.StartEncoding.Text );

                        // With cleanup
                        try
                        {
                            // Process it
                            if (!pEncoder.WaitForExit())
                                throw new Exception( StringResources.Strings.EncodingFailed.Text );
                        }
                        finally
                        {
                            // Done with input
                            pIn.Close();
                        }
                    }

                    // Report
                    if (configuration.DebugOutput)
                        if (!unattended)
                            EncodingError.Show( pLog.ToString() );

                    // Woo, we did it!
                    return 0;
                }
                catch (Exception e)
                {
                    // Extend
                    pLog.AddString( e.ToString() );

                    // Create logger
                    if (!unattended)
                        EncodingError.Show( pLog.ToString() );

                    // Report error
                    return -1;
                }
        }