Пример #1
0
        private void InitRecord()
        {
            sfd = new SaveFileDialog();
            try
            {
                string   strFormat;
                IMFProps props;
                mWriter.WriterOptionGet(eMFWriterOption.eMFWO_Format, out strFormat, out props);

                string protocol = "";
                props.PropsGet("protocol", out protocol);
                string network = "";
                props.PropsGet("network", out network);

                //if(network == "true" || protocol.Contains("udp") || protocol.Contains("rtmp") || protocol.Contains("rtsp")) && textBoxURL.Text.Length > 0)
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    mWriter.WriterSet(sfd.FileName, 1, "format = 'webm' video::codec = 'libvpx' audio::codec = 'libvorbis'");
                }
                isRec = true;
            }
            catch (Exception e)
            {
                MessageBox.Show("Error:  " + e.ToString());
            }
        }
Пример #2
0
        private void buttonStartRec_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            try
            {
                string   strFormat;
                IMFProps props;
                m_objWriter.WriterOptionGet(eMFWriterOption.eMFWO_Format, out strFormat, out props);
                if (audio_channels.Checked)
                {
                    m_objLive.PropsSet("audio_channels", "0+2+4+6,1+3+5+7,0,1,2,3,4,5,6,7");
                }
                string sProtocol;
                props.PropsGet("protocol", out sProtocol);
                if (sProtocol == null)
                {
                    sProtocol = "";
                }
                string bNetwork = "";
                props.PropsGet("network", out bNetwork);

                if ((bNetwork == "true" || sProtocol.Contains("udp") || sProtocol.Contains("rtmp") || sProtocol.Contains("rtsp")) && textBoxURL.Text.Length > 0)
                {
                    try
                    {
                        m_objWriter.WriterSet(textBoxURL.Text, 0, textBoxConfig.Text);
                        rec = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
                else if (strFormat == "Auto Select")
                {
                    sfd.Filter = "MPEG files (*.mp4)|*.mp4|All Files (*.*)|*.*";

                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        m_objWriter.WriterSet(sfd.FileName, 0, " format='mp4' video::codec='mpeg4' video::b='5M' audio::codec='aac'");
                        rec = true;
                    }
                }
                else
                {
                    //Choose file extension
                    string strExtensions;
                    props.PropsGet("extensions", out strExtensions);
                    Marshal.ReleaseComObject(props);

                    string[] arrExt       = strExtensions.Split(',');
                    string   strFilterExt = ""; // (*.yyy;*.xxx)
                    for (int i = 0; i < arrExt.Length; i++)
                    {
                        if (strFilterExt.Length > 0)
                        {
                            strFilterExt += ";*." + arrExt[i];
                        }
                        else
                        {
                            strFilterExt = "*." + arrExt[i];
                        }
                    }

                    sfd.Filter = strFormat + " Files (" + strFilterExt + ")|" + strFilterExt + "|All Files (*.*)|*.*";

                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        m_objWriter.WriterSet(sfd.FileName, 0, textBoxConfig.Text);
                        rec = true;
                    }
                }
            }
            catch (Exception)
            { }
        }