public void BeginRecord(string profile)
        {
            // Create WMEncoder object.
            //Get group collection
            IWMEncSourceGroupCollection SrcGrpColl = m_Encoder.SourceGroupCollection;
            //Add group into collection
            IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("SG_1");
            //Add audio source and video source into group
            //IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
            //SrcAud.SetInput("Default_Audio_Device", "Device", "");
            IWMEncVideoSource2 SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);

            SrcVid.SetInput("ScreenCapture1", "ScreenCap", "");
            //Load profile config.
            if (String.IsNullOrEmpty(profile))
            {
                if (SelectUserProFile != null)
                {
                    List <string> lstPFs = new List <string>();
                    foreach (IWMEncProfile pro in m_Encoder.ProfileCollection)
                    {
                        lstPFs.Add(pro.Name);
                    }
                    profile = SelectUserProFile(lstPFs.ToArray());
                }
            }
            if (!String.IsNullOrEmpty(profile))
            {
                foreach (IWMEncProfile pro in m_Encoder.ProfileCollection)
                {
                    if (pro.Name == profile)
                    {
                        SrcGrp.set_Profile(pro);
                        break;
                    }
                }
            }
            //Pro.LoadFromFile(prxFileName);
            //SrcGrp.set_Profile(Pro);
            //Add the display information of output video file.
            IWMEncDisplayInfo Descr = m_Encoder.DisplayInfo;

            Descr.Title       = "Screen Recorder Video";
            Descr.Author      = Environment.UserName;
            Descr.Description = "";
            Descr.Rating      = "";
            Descr.Copyright   = "";
            //IWMEncAttributes Attr = Encoder.Attributes;
            //Attr.Add("URL", "IP address");
            //Prepare to encode
            //videoEncoder.PrepareToEncode(true);
            //Record start
            //Specify output file path
            if (!Directory.Exists(SavePath))
            {
                Directory.CreateDirectory(SavePath);
            }
            m_Encoder.File.LocalFileName = String.Format("{0}RecordFile{1}.wmv", SavePath, CurNewFileTailIndex);
            m_Encoder.Start();
        }
Example #2
0
        public void InitializeEncoder()
        {
            try
            {
                frm_Rec        = new WebMeeting.Client.Screen_Capture.frm_Rec();
                config         = new Config();
                config.cfgFile = "WebMeeting.exe.config";

                // create encoder object
                m_encoder = new WMEncoder();
                m_encoder.DisplayInfo.Author      = "Zaeem";
                m_encoder.DisplayInfo.Copyright   = "Uraan Software Solutions";
                m_encoder.DisplayInfo.Description = "Uraan Generated Media File for Screen Recording";
                m_encoder.DisplayInfo.Title       = "Recorded Screen";
                m_encoder.DisplayInfo.Title       = "Recorded Screen";
                m_encoder.DisplayInfo.Rating      = "1";
                m_encoder.DisplayInfo.Description = "This file is Generated through CampusNav developed by Uraan Software Solution";



                // retrive source group collection
                m_sourceGroupCollection = m_encoder.SourceGroupCollection;

                // add a source group to collection
                m_srcGrp = m_sourceGroupCollection.Add("SG_1");

                m_sourceEnumDlg = new SourceEnum();

                // add a screen source
                if (EnumerateAudioSources())
                {
                    m_audSource = m_srcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
                    m_audSource.SetInput(m_szAudioSource, "Device", "");
                }

                // set screen as source
                m_screenSource = (IWMEncVideoSource2)m_srcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                m_screenSource.SetInput("ScreenCapture1", "ScreenCap", "");
            }
            catch (Exception exp)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Video Recordong Module ===>Screen Capture.cs line==> 99", exp, "Error Loading Encoder: " + exp.Message.ToString(), false);
                if (MessageBox.Show("Either You do not have required components of Windows Media Encoder or they are corrupted on your Machine: " + /*+exp.Message.ToString() + */ ". Do you want to download now?", "WebMeeting", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    Win32.Shell32.ShellExecute(0, "Open", WebMeeting.Client.Info.getInstance().WebsiteName + "/wmencoder.exe", "", "", 1);
                }

                //WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Error Stoping encoder: " + exp.Message.ToString());
                //Trace.WriteLine(exp.ToString()+"---"+exp.Message+"---"+exp.Source+exp.StackTrace+"---"+exp.TargetSite+"---"+exp.InnerException);
            }
        }
Example #3
0
    static void Main()
    {
        try
        {
            // Create a WMEncoder object.
            WMEncoder Encoder = new WMEncoder();

            // Retrieve the source group collection.
            IWMEncSourceGroupCollection SrcGrpColl = Encoder.SourceGroupCollection;

            // Add a source group to the collection.
            IWMEncSourceGroup SrcGrp = SrcGrpColl.Add("SG_1");

            // Add a video and audio source to the source group.
            IWMEncSource SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
            SrcAud.SetInput("C:\\Inputfile.mpg", "", "");

            IWMEncVideoSource2 SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
            SrcVid.SetInput("C:\\Inputfile.mpg", "", "");

            // Crop 2 pixels from each edge of the video image.
            SrcVid.CroppingBottomMargin = 2;
            SrcVid.CroppingTopMargin    = 2;
            SrcVid.CroppingLeftMargin   = 2;
            SrcVid.CroppingRightMargin  = 2;

            // Specify a file object in which to save encoded content.
            IWMEncFile File = Encoder.File;
            File.LocalFileName = "C:\\OutputFile.wmv";

            // Choose a profile from the collection.
            IWMEncProfileCollection ProColl = Encoder.ProfileCollection;
            IWMEncProfile           Pro;
            for (int i = 0; i < ProColl.Count; i++)
            {
                Pro = ProColl.Item(i);
                if (Pro.Name == "Windows Media Video 8 for Local Area Network (384 Kbps)")
                {
                    SrcGrp.set_Profile(Pro);
                    break;
                }
            }

            // Fill in the description object members.
            IWMEncDisplayInfo Descr = Encoder.DisplayInfo;
            Descr.Author      = "Author name";
            Descr.Copyright   = "Copyright information";
            Descr.Description = "Text description of encoded content";
            Descr.Rating      = "Rating information";
            Descr.Title       = "Title of encoded content";

            // Add an attribute to the collection.
            IWMEncAttributes Attr = Encoder.Attributes;
            Attr.Add("URL", "IP address");

            // Start the encoding process.
            // Wait until the encoding process stops before exiting the application.
            Encoder.PrepareToEncode(true);
            Encoder.Start();
            Console.WriteLine("Press Enter when the file has been encoded.");
            Console.ReadLine();     // Press Enter after the file has been encoded.
        }
        catch (Exception e)
        {
            // TODO: Handle exceptions.
        }
    }
Example #4
0
        public void InitializeEncoder()
        {
            try
            {
                frm_Rec=new WebMeeting.Client.Screen_Capture.frm_Rec();
                config=new Config();
                config.cfgFile = "WebMeeting.exe.config";

                // create encoder object
                m_encoder = new WMEncoder();
                m_encoder.DisplayInfo.Author="Zaeem";
                m_encoder.DisplayInfo.Copyright="Uraan Software Solutions";
                m_encoder.DisplayInfo.Description="Uraan Generated Media File for Screen Recording";
                m_encoder.DisplayInfo.Title="Recorded Screen";
                m_encoder.DisplayInfo.Title="Recorded Screen";
                m_encoder.DisplayInfo.Rating="1";
                m_encoder.DisplayInfo.Description="This file is Generated through CampusNav developed by Uraan Software Solution";

                // retrive source group collection
                m_sourceGroupCollection = m_encoder.SourceGroupCollection;

                // add a source group to collection
                m_srcGrp = m_sourceGroupCollection.Add("SG_1");

                m_sourceEnumDlg= new SourceEnum();

                // add a screen source
                if(EnumerateAudioSources())
                {
                    m_audSource = m_srcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
                    m_audSource.SetInput(m_szAudioSource, "Device", "");
                }

                // set screen as source
                m_screenSource = (IWMEncVideoSource2)m_srcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                m_screenSource.SetInput("ScreenCapture1", "ScreenCap", "");

            }
            catch(Exception  exp)
            {

                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Video Recordong Module ===>Screen Capture.cs line==> 99",exp,"Error Loading Encoder: " + exp.Message.ToString(),false);
                if( MessageBox.Show("Either You do not have required components of Windows Media Encoder or they are corrupted on your Machine: "+ /*+exp.Message.ToString() + */". Do you want to download now?","WebMeeting",MessageBoxButtons.YesNo,MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    Win32.Shell32.ShellExecute(0,"Open",WebMeeting.Client.Info.getInstance().WebsiteName + "/wmencoder.exe","","",1);
                }

                //WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Error Stoping encoder: " + exp.Message.ToString());
                //Trace.WriteLine(exp.ToString()+"---"+exp.Message+"---"+exp.Source+exp.StackTrace+"---"+exp.TargetSite+"---"+exp.InnerException);

            }
        }
Example #5
0
        //To Start the Recording.
        private void startRecordingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IWMEncProfile SelProfile;
            IWMEncSource  AudioSrc;

            try
            {
                if (DesktopEncoder != null)
                {
                    if (DesktopEncoder.RunState == WMENC_ENCODER_STATE.WMENC_ENCODER_PAUSED)
                    {
                        DesktopEncoder.Start();
                        return;
                    }
                }
                DesktopEncoderAppln = new WMEncoderApp();
                DesktopEncoder      = DesktopEncoderAppln.Encoder;
                IWMEncSourceGroupCollection SrcGroupCollection = DesktopEncoder.SourceGroupCollection;
                IWMEncSourceGroup           SrcGroup           = SrcGroupCollection.Add("SG_1");
                IWMEncVideoSource2          VideoSrc           = (IWMEncVideoSource2)SrcGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                //Set Audio Source.
                if (addAudio.Checked)
                {
                    AudioSrc = SrcGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
                    if (txtAudioFile.Text.Trim() != "")
                    {
                        if (File.Exists(txtAudioFile.Text.Trim()))
                        {
                            AudioSrc.SetInput(txtAudioFile.Text.Trim(), "", "");
                        }
                        else
                        {
                            AudioSrc.SetInput("Default_Audio_Device", "Device", "");
                        }
                    }
                    else
                    {
                        AudioSrc.SetInput("Default_Audio_Device", "Device", "");
                    }
                }
                //Set Video Source:Desktop.
                VideoSrc.SetInput("ScreenCapture1", "ScreenCap", "");
                IWMEncProfileCollection ProfileCollection = DesktopEncoder.ProfileCollection;
                ProfileCollection = DesktopEncoder.ProfileCollection;
                int lLength = ProfileCollection.Count;
                //Set Profile.
                if (toolstripEnableBroadcast.Checked && txtPortNbr.Text.Trim() != "")
                {
                    IWMEncBroadcast broadcast = DesktopEncoder.Broadcast;
                    broadcast.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, Convert.ToInt32(txtPortNbr.Text.Trim()));
                    for (int i = 0; i <= lLength - 1; i++)
                    {
                        SelProfile = ProfileCollection.Item(i);
                        if (SelProfile.Name == "Windows Media Video 8 for Local Area Network (768 Kbps)")
                        {
                            SrcGroup.set_Profile((IWMEncProfile)SelProfile);
                            break;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i <= lLength - 1; i++)
                    {
                        SelProfile = ProfileCollection.Item(i);
                        if (SelProfile.Name == "Screen Video/Audio High (CBR)")
                        {
                            SrcGroup.set_Profile((IWMEncProfile)SelProfile);
                            break;
                        }
                    }
                }
                //Local File to Store Recording temporarily.
                IWMEncFile inputFile = DesktopEncoder.File;
                inputFile.LocalFileName = "C:\\TempRecording.wmv";
                DesktopEncoder.PrepareToEncode(true);
                DesktopEncoder.Start();
                tmrRcCounter.Enabled = true;
                recordStarttime      = DateTime.Now;
                if (toolstripEnableBroadcast.Checked && txtPortNbr.Text.Trim() != "")
                {
                    //Start Timer to Count Viewers connected to Broadcast.
                    tmrViewerCount.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #6
0
        private void InitializeEncoder()
        {
            SrcGrpColl = Encoder.SourceGroupCollection;
            SrcGrp = SrcGrpColl.Add("SG_1");
            SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
            SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
            SrcAud.SetInput("Default_Audio_Device", "Device", "");
            SrcVid.SetInput("Default_Video_Device", "Device", "");

            ProColl = Encoder.ProfileCollection;

            for (int i = 0; i < ProColl.Count; i++)
            {
                Pro = ProColl.Item(i);
                data.Add(Pro.Name);

                if (Pro.Name == Codec)
                {
                    SrcGrp.set_Profile(Pro);
                    break;
                }
            }
            BrdCst = Encoder.Broadcast;
            BrdCst.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, Port);
        }
        void _backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string                  glbstrErrLocation;
            WMEncoder               Encoder    = null;
            WMEncProfile2           Profile    = null;
            IWMDRMContentAuthor     DRMAuthor  = null;
            IWMDRMProfileCollection DRMProColl = null;
            IWMDRMProfile           DRMPro     = null;
            IWMEncSourceGroup       SrcGrp     = null;
            IWMEncAudioSource       SrcAud     = null;
            IWMEncVideoSource2      SrcVid     = null;

            _TwoPassEncoding = false;


            bool glbboolEncodingContinue = true;;

            DateTime time = DateTime.Now;

            try
            {
                Encoder = new WMEncoder();
                Encoder.OnStateChange += new _IWMEncoderEvents_OnStateChangeEventHandler(this.Encoder_OnStateChange);
                _SrcGrpColl            = Encoder.SourceGroupCollection;

                try
                {
                    DRMAuthor  = Encoder.EncoderDRMContentAuthor;
                    DRMProColl = DRMAuthor.DRMProfileCollection;
                    DRMPro     = null;

                    object vKeyID = null;
                    if (_encodeInfo.DRMProfile != "None")
                    {
                        int intDRMProCount = 0;
                        for (intDRMProCount = 0; intDRMProCount <= DRMProColl.Count - 1; intDRMProCount++)
                        {
                            if (DRMProColl.Item(intDRMProCount).Name == _encodeInfo.DRMProfile)
                            {
                                DRMPro = DRMProColl.Item(intDRMProCount);
                                break;
                            }
                        }
                        DRMAuthor.SetSessionDRMProfile(DRMPro.ID, ref vKeyID);
                    }
                    else
                    {
                        DRMAuthor.SetSessionDRMProfile(System.DBNull.Value.ToString(), ref vKeyID);
                        DRMAuthor  = null;
                        DRMProColl = null;
                        DRMPro     = null;
                        vKeyID     = null;
                    }
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Specify DRM Profile - " + ex.Message.ToString();
                    throw new ApplicationException(glbstrErrLocation, ex);
                }
                Profile = new WMEncProfile2();
                Int32 intProContentType  = 0;
                int   intProVBRModeAudio = 0;
                int   intProVBRModeVideo = 0;
                try
                {
                    Profile.LoadFromFile(_encodeInfo.Profile);
                    intProContentType  = Profile.ContentType;
                    intProVBRModeAudio = (int)Profile.get_VBRMode(WMENC_SOURCE_TYPE.WMENC_AUDIO, 0);
                    intProVBRModeVideo = (int)Profile.get_VBRMode(WMENC_SOURCE_TYPE.WMENC_VIDEO, 0);
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Load Profile - " + ex.Message.ToString();
                    throw new ApplicationException(glbstrErrLocation, ex);
                }

                try
                {
                    SrcGrp = _SrcGrpColl.Add("BatchEncode");
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Source Group - " + ex.Message.ToString();
                    throw new ApplicationException(glbstrErrLocation, ex);
                }
                string strDestExtension = System.IO.Path.GetExtension(_encodeInfo.Destination);

                try
                {
                    if (intProContentType == 1)
                    {
                        SrcAud = (WMEncoderLib.IWMEncAudioSource)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
                        SrcAud.SetInput(_encodeInfo.Source, "", "");
                    }
                    else if (intProContentType == 16)
                    {
                        SrcVid = (WMEncoderLib.IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                        SrcVid.SetInput(_encodeInfo.Source, "", "");
                    }
                    else if (intProContentType == 17)
                    {
                        SrcAud = (WMEncoderLib.IWMEncAudioSource)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
                        SrcAud.SetInput(_encodeInfo.Source, "", "");
                        SrcVid = (WMEncoderLib.IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                        SrcVid.SetInput(_encodeInfo.Source, "", "");
                    }
                    else
                    {
                        _backgroundWorker.ReportProgress(0, "BatchEncode does not support this type of profile");
                    }
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Video / Audio Source - " + ex.Message.ToString();
                    throw new ApplicationException(glbstrErrLocation, ex);
                }
                try
                {
                    SrcGrp.set_Profile(Profile);
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Encoding Profile - " + ex.Message.ToString();

                    throw new ApplicationException(glbstrErrLocation, ex);
                }
                IWMEncDisplayInfo Descr = Encoder.DisplayInfo;
                try
                {
                    if (_encodeInfo.Title != "")
                    {
                        Descr.Title = _encodeInfo.Title;
                    }
                    if (_encodeInfo.Description != "")
                    {
                        Descr.Description = _encodeInfo.Description;
                    }
                    if (_encodeInfo.Author != "")
                    {
                        Descr.Author = _encodeInfo.Author;
                    }
                    if (_encodeInfo.Copyright != "")
                    {
                        Descr.Copyright = _encodeInfo.Copyright;
                    }
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Display Information - " + ex.Message.ToString();
                    throw new ApplicationException(glbstrErrLocation, ex);
                }
                try
                {
                    if (intProContentType == 16 || intProContentType == 17)
                    {
                        if (_encodeInfo.Crop == true)
                        {
                            SrcVid.CroppingBottomMargin = (int)_encodeInfo.CropBottom;
                            SrcVid.CroppingTopMargin    = (int)_encodeInfo.CropTop;
                            SrcVid.CroppingLeftMargin   = (int)_encodeInfo.CropLeft;
                            SrcVid.CroppingRightMargin  = (int)_encodeInfo.CropRight;
                        }
                    }
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Cropping - " + ex.Message.ToString();
                    throw new ApplicationException(glbstrErrLocation, ex);
                }
                try
                {
                    if (intProContentType == 16 || intProContentType == 17)
                    {
                        SrcVid.Optimization = _encodeInfo.Preproc;
                    }
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Video Optimization - " + ex.Message.ToString();
                    throw new ApplicationException(glbstrErrLocation, ex);
                }

                try
                {
                    if (intProContentType == 1)
                    {
                        if (_encodeInfo.TwoPass == false)
                        {
                            SrcAud.PreProcessPass = 0;
                            _TwoPassEncoding      = false;
                        }
                        else
                        {
                            SrcAud.PreProcessPass = 1;
                            _TwoPassEncoding      = true;
                            glbPassNumber         = 1;
                        }
                    }
                    else if (intProContentType == 16)
                    {
                        if (_encodeInfo.TwoPass == false)
                        {
                            SrcVid.PreProcessPass = 0;
                            _TwoPassEncoding      = false;
                        }
                        else
                        {
                            SrcVid.PreProcessPass = 1;
                            _TwoPassEncoding      = true;
                            glbPassNumber         = 1;
                        }
                    }
                    else if (intProContentType == 17)
                    {
                        if (_encodeInfo.TwoPass == false)
                        {
                            SrcAud.PreProcessPass = 0;
                            SrcVid.PreProcessPass = 0;
                            _TwoPassEncoding      = false;
                        }
                        else
                        {
                            switch (intProVBRModeAudio)
                            {
                            case 1:
                                SrcAud.PreProcessPass = 1;
                                break;

                            case 2:
                                SrcAud.PreProcessPass = 1;
                                break;

                            case 3:
                                SrcAud.PreProcessPass = 0;
                                break;

                            case 4:
                                SrcAud.PreProcessPass = 1;
                                break;
                            }
                            switch (intProVBRModeVideo)
                            {
                            case 1:
                                SrcVid.PreProcessPass = 1;
                                break;

                            case 2:
                                SrcVid.PreProcessPass = 1;
                                break;

                            case 3:
                                SrcVid.PreProcessPass = 0;
                                break;

                            case 4:
                                SrcVid.PreProcessPass = 1;
                                break;
                            }
                            _TwoPassEncoding = true;
                            glbPassNumber    = 1;
                        }
                    }
                    else
                    {
                        _backgroundWorker.ReportProgress(0, "BatchEncode does not support this type of profile");
                    }
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Passes - " + ex.Message.ToString();
                    throw new ApplicationException(glbstrErrLocation, ex);
                }
                IWMEncFile2 File = (IWMEncFile2)Encoder.File;
                try
                {
                    File.LocalFileName = _encodeInfo.Destination;
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Output File - " + ex.Message.ToString();
                    throw new ApplicationException(glbstrErrLocation, ex);
                }
                int intDurationAudio = 0;
                int intDurationVideo = 0;
                int intDurationFinal;
                try
                {
                    _backgroundWorker.ReportProgress(0, "Preparing to encode");
                    Encoder.PrepareToEncode(true);
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Encoder Prepare - " + ex.Message.ToString();


                    throw new ApplicationException(glbstrErrLocation, ex);
                }
                try
                {
                    if (SrcAud != null)
                    {
                        intDurationAudio = System.Convert.ToInt32(SrcAud.Duration / 1000);
                    }
                }
                catch (Exception)
                {
                }
                try
                {
                    if (SrcVid != null)
                    {
                        intDurationVideo = System.Convert.ToInt32(SrcVid.Duration / 1000);
                    }
                }
                catch (Exception)
                {
                }
                if (intDurationAudio == 0)
                {
                    intDurationFinal = intDurationVideo;
                }
                else if (intDurationVideo == 0)
                {
                    intDurationFinal = intDurationAudio;
                }
                else
                {
                    if (intDurationVideo >= intDurationAudio)
                    {
                        intDurationFinal = intDurationVideo;
                    }
                    else
                    {
                        intDurationFinal = intDurationAudio;
                    }
                }
                glbintSourceDuration = intDurationFinal;
                try
                {
                    if (glbboolEncodingContinue == true)
                    {
                        Encoder.Start();
                        do
                        {
                            if (_backgroundWorker.CancellationPending)
                            {
                                Encoder.Stop();
                                e.Cancel = true;
                                _ev.Set();
                            }

                            sReportPercentComplete(Encoder);
                        }while (!_ev.WaitOne(1000));
                    }
                }
                catch (Exception ex)
                {
                    glbstrErrLocation = "Encoder Start - " + ex.Message.ToString();
                    throw new ApplicationException(glbstrErrLocation, ex);
                }
                if (e.Cancel)
                {
                    return;
                }
                else
                {
                    _backgroundWorker.ReportProgress(0, "Encoding Complete");
                    return;
                }
            }
            finally
            {
                if (_SrcGrpColl != null)
                {
                    try
                    {
                        Encoder.Stop();
                        _SrcGrpColl.Remove(0);
                    }
                    catch
                    {
                    }
                    Marshal.ReleaseComObject(_SrcGrpColl);
                    _SrcGrpColl = null;
                }
                if (Profile != null)
                {
                    Marshal.ReleaseComObject(Profile);
                    Profile = null;
                }
                if (Encoder != null)
                {
                    Encoder.OnStateChange -= new _IWMEncoderEvents_OnStateChangeEventHandler(this.Encoder_OnStateChange);
                    Marshal.ReleaseComObject(Encoder);
                    Encoder = null;
                }
                e.Result = DateTime.Now - time;
            }
        }