Exemplo n.º 1
0
        private bool OpenConverter(bool first)
        {
            try
            {
                mConverter = new CAVConverter();
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                if (first)
                {
                    if (ex.ErrorCode == -2147221164)
                    {
                        if (!RegisterCAVEditLib())
                        {
                            return(false);
                        }
                        return(OpenConverter(false));
                    }
                    else
                    {
                        richTextBoxLog.Text += "\r\n";
                        richTextBoxLog.Text += "*** " + ex.Message;
                        richTextBoxLog.Text += "\r\n";
                        return(false);
                    }
                }
                else
                {
                    richTextBoxLog.Text += "\r\n";
                    richTextBoxLog.Text += "*** " + ex.Message;
                    richTextBoxLog.Text += "\r\n";
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public void SetConverter(ICAVConverter Converter)
        {
            ClearFrameView();
            mConverter = Converter;
            richTextBoxMediaInfo.Text = mConverter.AVPrope.FileInfoText;
            // NOTICE: this demo application only shows first video stream &&/or first audio stream.
            mVideoStreamIndex = mConverter.AVPrope.FirstVideoStreamIndex;
            mAudioStreamIndex = mConverter.AVPrope.FirstAudioStreamIndex;

            // whether we can seek or not
            trackBarPreview.Enabled = (mConverter.AVPrope.FileStreamInfo.Duration != (long)AV_NOPTS_VALUE) && (mConverter.AVPrope.FormatName != "image2");

            // file duration
            if (mConverter.AVPrope.FileStreamInfo.Duration != (long)AV_NOPTS_VALUE)
                mDuration = mConverter.AVPrope.FileStreamInfo.Duration;

            // calculate Frames of the first video stream, use it for the track bar max position
            if ((mConverter.AVPrope.VideoStreamCount > 0) && (mConverter.AVPrope.FirstVideoStreamInfo.FrameRate.den > 0))
            {
                if (mConverter.AVPrope.FirstVideoStreamInfo.DurationScaled > 0)
                    mFrames = (int)Math.Round((double)mConverter.AVPrope.FirstVideoStreamInfo.DurationScaled / AV_TIME_BASE *
                                mConverter.AVPrope.FirstVideoStreamInfo.FrameRate.num / mConverter.AVPrope.FirstVideoStreamInfo.FrameRate.den);
                else if (mConverter.AVPrope.FileStreamInfo.Duration != (long)AV_NOPTS_VALUE)
                    mFrames = (int)Math.Round((double)mConverter.AVPrope.FileStreamInfo.Duration / AV_TIME_BASE *
                                mConverter.AVPrope.FirstVideoStreamInfo.FrameRate.num / mConverter.AVPrope.FirstVideoStreamInfo.FrameRate.den);
            }
            else if (mConverter.AVPrope.FileStreamInfo.Duration != (long)AV_NOPTS_VALUE)
                mFrames = (int)Math.Round((double)mConverter.AVPrope.FileStreamInfo.Duration / AV_TIME_BASE * 10);

            // if video stream available, then read && draw the first frame
            if (mConverter.AVPrope.VideoStreamCount > 0)
                ReadAndDrawNextFrame();

            // setup track bar for seeking
            SetupTrackBar();
        }
Exemplo n.º 3
0
Arquivo: Main.cs Projeto: ORRNY66/GS
        private bool OpenConverter(bool first)
        {
            try
            {
                mConverter = new CAVConverter();
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                if (first)
                {
                    if (ex.ErrorCode == -2147221164)
                    {
                        if (!RegisterCAVEditLib())
                        {
                            return false;
                        }
                        return OpenConverter(false);
                    }
                    else
                    {
                        richTextBoxLog.Text += "\r\n";
                        richTextBoxLog.Text += "*** " + ex.Message;
                        richTextBoxLog.Text += "\r\n";
                        return false;
                    }
                }
                else
                {
                    richTextBoxLog.Text += "\r\n";
                    richTextBoxLog.Text += "*** " + ex.Message;
                    richTextBoxLog.Text += "\r\n";
                    return false;
                }

            }

            return true;
        }