Beispiel #1
0
        private void btnPreview_Click(object sender, EventArgs e)
        {
            var selItems = lvVideoFiles.SelectedIndices;

            if (selItems == null)
            {
                return;
            }
            int sel = selItems[0];

            _player.Stop();
            _media.Dispose();

            VideoFileInfo       vfi     = _videoFiles[sel];
            IMediaPlayerFactory factory = new MediaPlayerFactory();

            _media  = factory.CreateMedia <IMediaFromFile>(vfi.FileFullName);
            _player = factory.CreatePlayer <IVideoPlayer>();
            _player.WindowHandle = picturePreview.Handle;
            _player.AspectRatio  = AspectRatioMode.Mode2;
            _player.Open(_media);
            _player.Events.MediaEnded    += new EventHandler(OnMediaEnded);
            _player.Events.PlayerStopped += new EventHandler(OnPlayerStopped);
            _player.Play();
        }
Beispiel #2
0
        void PlayPreviewFile(string FileName)
        {
            try
            {
                _player.Stop();
                _player.Dispose();
            }
            catch { }
            try
            {
                _media.Dispose();
            }
            catch { }

            IMediaPlayerFactory factory = new MediaPlayerFactory();

            _media  = factory.CreateMedia <IMediaFromFile>(FileName);
            _player = factory.CreatePlayer <IVideoPlayer>();
            _player.WindowHandle = picturePreview.Handle;
            _player.AspectRatio  = AspectRatioMode.Mode2; // fill?
            _player.Open(_media);
            _player.Events.MediaEnded    += new EventHandler(OnMediaEnded);
            _player.Events.PlayerStopped += new EventHandler(OnPlayerStopped);
            _player.Play();
        }
Beispiel #3
0
        /// <summary>
        /// 截取视频缩略图
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="imgFile"></param>
        /// <returns></returns>
        public static bool CatchImg(string fileName, string imgFile)
        {
            const string ffmpeg = "ffmpeg.exe";
            //string flvImg = imgFile + ".jpg";
            string flvImgSize = "640*480";
            MediaPlayerFactory m_factory = new MediaPlayerFactory();
            IVideoPlayer m_player = m_factory.CreatePlayer<IVideoPlayer>();
            IMediaFromFile m_media = m_factory.CreateMedia<IMediaFromFile>(fileName);
            m_player.Open(m_media);
            m_media.Parse(true);

            System.Drawing.Size size = m_player.GetVideoSize(0);
            if (!size.IsEmpty)
                flvImgSize = size.Width.ToString() + "*" + size.Height.ToString();
            //m_player.TakeSnapShot(1, @"C:");
            System.Diagnostics.ProcessStartInfo ImgstartInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
            ImgstartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            ImgstartInfo.Arguments = "   -i   " + fileName + "  -y  -f  image2   -ss 2 -vframes 1  -s   " + flvImgSize +
                                     "   " + imgFile;
            try
            {
                System.Diagnostics.Process.Start(ImgstartInfo);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return false;
            }
            return true;
        }
Beispiel #4
0
        private void button7_Click(object sender, EventArgs e)
        {
            run = true;
            Thread t = new Thread(() =>
            {
                int thisCount = countSave++;
                if (!string.IsNullOrEmpty(textBox1.Text))
                {
                    var factory = new MediaPlayerFactory();
                    var player  = factory.CreatePlayer <IDiskPlayer>();

                    player.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
                    player.Events.TimeChanged           += new EventHandler <MediaPlayerTimeChanged>(Events_TimeChanged);
                    player.Events.MediaEnded            += new EventHandler(Events_MediaEnded);
                    player.Events.PlayerStopped         += new EventHandler(Events_PlayerStopped);


                    trackBar2.Value = player.Volume;

                    // string output = ":sout=file:abc.mp4";

                    // string output = ":sout=#transcode{vcodec=h264,vb=0,scale=0,acodec=mpga,ab=128,channels=2,samplerate=44100}:duplicate{dst=file{dst=abc.mp4}";//,dst=display}
                    // string output1 = ":demux=dump :demuxdump-file=output.mp4";

                    while (run)
                    {
                        try
                        {
                            string fileName = "data\\" + thisCount + "-" + DateTime.Now.ToLongTimeString();
                            string output   = ":sout=#transcode{demux=dump}:duplicate{dst=file{dst=" + fileName + ".mp4},dst=rtp{sdp=rtsp://:42624/test},dst=http{mux=ffmpeg{mux=flv},dst=:48684/}}";//,dst=display} dst=rtp{sdp=rtsp://:8554/},dst=http{mux=ffmpeg{mux=flv},dst=:8080/}

                            var media = m_factory.CreateMedia <IMedia>(textBox1.Text, output);
                            media.Events.DurationChanged += new EventHandler <MediaDurationChange>(Events_DurationChanged);
                            media.Events.StateChanged    += new EventHandler <MediaStateChange>(Events_StateChanged);
                            media.Events.ParsedChanged   += new EventHandler <MediaParseChange>(Events_ParsedChanged);

                            player.Open(media);
                            media.Parse(true);

                            player.Play();

                            Thread.Sleep(60000);
                            player.Stop();
                        }
                        catch { }
                    }
                }
                else
                {
                    errorProvider1.SetError(textBox1, "Please select media path first !");
                }
            });

            t.Start();
        }
Beispiel #5
0
        private void RecordingForm_Load(object sender, EventArgs e)
        {
            IMediaPlayerFactory factory = new MediaPlayerFactory();

            //_media = factory.CreateMedia<IMedia>("rtsp://*****:*****@" + DefaultConfig.CameraIP + ":554/cam/realmonitor?channel=1&subtype=1", DefaultConfig.PlayerOptions);
            //xcg
            _media              = factory.CreateMedia <IMedia>("rtsp://*****:*****@" + cameraIP + ":554/cam/realmonitor?channel=1&subtype=1", DefaultConfig.PlayerOptions);
            _player             = factory.CreatePlayer <IVideoPlayer>();
            _player.AspectRatio = AspectRatioMode.Mode2;
            _player.Open(_media);
            _player.Play();
        }
Beispiel #6
0
        private void VideoForm_Load_1(object sender, EventArgs e)
        {
            //文字浮动
            toolTip1.SetToolTip(btn_play, "播放");
            toolTip1.SetToolTip(btn_pause, "暂停");
            toolTip1.SetToolTip(btn_close, "隐藏");
            m_ptCanvas = this.pictureBox_Video.Location;
            if (playBack.nfi == null)
            {
                Close();
                return;
            }

            IMediaPlayerFactory factory = new MediaPlayerFactory();

            //创建播放器
            PlayerVideo = factory.CreatePlayer <IVideoPlayer>();

            //窗口句柄(在picture_Box上播放视频)
            PlayerVideo.WindowHandle = pictureBox_Video.Handle;

            //宽高比(4:3,16:9等等)
            PlayerVideo.AspectRatio = AspectRatioMode.Mode2;
            if (playBack.nfi.HasVideo)
            {
                //获得media视频文件
                Media = factory.CreateMedia <IMediaFromFile>(playBack.nfi.VideoFullName);

                //打开该文件
                PlayerVideo.Open(Media);
                PlayerVideo.PlaybackRate = playBack.Speed;
                PlayerVideo.Play();
//                PlayerVideo.Time = (long)(playBack.nfi.VideoOffset * 1000 + playBack.CurrentSeconds * 1000 + playBack.chartWave.ChartAreas[0].AxisX.StripLines[0].IntervalOffset * 1000+playBack.GetDvalue*1000);
                getOffsetTime();
            }
            //获得picturebox的X,Y值,宽,高
            x      = this.pictureBox_Video.Location.X;
            y      = this.pictureBox_Video.Location.Y;
            width  = this.pictureBox_Video.Width;
            height = this.pictureBox_Video.Height;
            if (playBack.Player.IsPlaying)
            {
                btn_pause.Enabled = true;
                btn_play.Enabled  = false;
            }
            else
            {
                btn_pause.Enabled = false;
                btn_play.Enabled  = true;
            }
        }
Beispiel #7
0
        public void PlayVideo(string url)
        {
            IMediaPlayerFactory factory = new MediaPlayerFactory();
            //:network-caching=300 :rtsp-caching=300
            IMedia media = factory.CreateMedia <IMedia>(url);
            //  IMedia media = factory.CreateMedia<IMedia>(url, new string[] { "network-caching=1000", "rtsp-caching=1000" });

            IVideoPlayer player = factory.CreatePlayer <IVideoPlayer>();

            player.WindowHandle = panel1.Handle;
            player.Open(media);
            player.Events.MediaEnded  += Events_MediaEnded;
            player.Events.TimeChanged += Events_TimeChanged;
            //       player.AspectRatio = AspectRatioMode.Default;
            player.Play();
        }
Beispiel #8
0
 public void Player_Setup(string sciezka)
 {
     factory = new MediaPlayerFactory(true);
     player  = factory.CreatePlayer <IDiskPlayer>();
     player.Events.PlayerPositionChanged += new EventHandler <MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
     player.Events.TimeChanged           += new EventHandler <MediaPlayerTimeChanged>(Events_TimeChanged);
     player.Events.MediaEnded            += new EventHandler(Events_MediaEnded);
     player.Events.PlayerStopped         += new EventHandler(Events_PlayerStopped);
     player.WindowHandle = PresentPanel.Handle;
     UISync.Init(this);
     med = factory.CreateMedia <IMediaFromFile>(sciezka);
     med.Events.DurationChanged += new EventHandler <MediaDurationChange>(Events_DurationChanged);
     med.Events.StateChanged    += new EventHandler <MediaStateChange>(Events_StateChanged);
     med.Events.ParsedChanged   += new EventHandler <MediaParseChange>(Events_ParsedChanged);
     player.Open(med);
     //  med.Parse(true);
 }
Beispiel #9
0
        public void Start(int index, string name, string url)
        {
            Index = index;
            Name  = name;

            IMediaPlayerFactory factory = new MediaPlayerFactory();
            IMedia media = factory.CreateMedia <IMedia>(url);

            m_player = factory.CreatePlayer <IVideoPlayer>();
            m_player.WindowHandle = this.Handle;

            memRender = m_player.CustomRenderer;
            memRender.SetFormat(new BitmapFormat(Width, Height, ChromaType.RV16));

            m_player.AspectRatio = Aspect_Ratio;
            m_player.Open(media);
            m_player.Play();
            timer1.Enabled = true;
        }
Beispiel #10
0
        private void PlaybackForm_Load(object sender, EventArgs e)
        {
            if (_nfi == null)
            {
                Close();
                return;
            }

            chartWave.Series.Clear();
            foreach (int idx in Enumerable.Range(0, 20))
            {
                Series ser = new Series();
                ser.ChartType       = SeriesChartType.FastLine;
                ser.BorderDashStyle = ChartDashStyle.Solid;
                //ser.Color = Color.Black;
                chartWave.Series.Add(ser);
            }
            chartWave.ChartAreas[0].AxisX.Maximum = WINDOW_SECONDS;
            //hsProgress.
            if (_nfi != null)
            {
                LoadData(0);
                ShowData();
            }

            IMediaPlayerFactory factory = new MediaPlayerFactory();

            _player = factory.CreatePlayer <IVideoPlayer>();
            _player.WindowHandle = panelVideo.Handle;
            //     _player.WindowHandle=pictureBox1.Handle;
            _player.AspectRatio = AspectRatioMode.Mode2; // fill?

            if (_nfi.HasVideo)
            {
                _media = factory.CreateMedia <IMediaFromFile>(_nfi.VideoFullName);
                _player.Open(_media);
                Debug.WriteLine(_player.IsSeekable);
                Debug.WriteLine(_player.Length);
                _player.Time = (long)_nfi.VideoOffset * 1000;
                //_player.Play();
                _player.Pause();
            }
        }
Beispiel #11
0
        public void Start(int index, string name, string url)
        {
            IMediaPlayerFactory factory = new MediaPlayerFactory();
            IMedia media = factory.CreateMedia <IMedia>(url);

            m_player = factory.CreatePlayer <IVideoPlayer>();
            m_player.WindowHandle = Handle;

            //IMemoryRenderer memRender = m_player.CustomRenderer;
            //memRender.SetCallback(delegate (Bitmap frame)
            //{
            //    // NewFrameEvent?.Invoke(frame, index, name);
            //    Console.WriteLine(frame.Size);
            //});

            //memRender.SetFormat(new BitmapFormat(704, 576, ChromaType.RV24));
            m_player.AspectRatio = Aspect_Ratio;
            m_player.Open(media);
            m_player.Play();
        }
Beispiel #12
0
        /// <summary>
        /// initVLClib
        /// </summary>
        void initVLClib()
        {
            try
            {
                p                       = new System.Windows.Forms.Panel();
                p.BackColor             = System.Drawing.Color.Black;
                windowsFormsHost1.Child = p;

                m_factory = new MediaPlayerFactory(true);
                m_player  = m_factory.CreatePlayer <IVideoPlayer>();

                this.DataContext = m_player;

                //m_player.Events.PlayerPositionChanged += new EventHandler<MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
                //m_player.Events.TimeChanged += new EventHandler<MediaPlayerTimeChanged>(Events_TimeChanged);
                //m_player.Events.MediaEnded += new EventHandler(Events_MediaEnded);
                //m_player.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);

                m_player.WindowHandle = p.Handle;
            }
            catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Ошибка библиотеки vlc " + ex.Message); }
        }
Beispiel #13
0
        private void TestVLC()
        {
            StopPlayer();
            try
            {
                _factory = new MediaPlayerFactory();
                _player  = _factory.CreatePlayer <IVideoPlayer>();

                _player.Open(_media);
                _player.Mute = true;
                _player.Events.PlayerPositionChanged  += EventsPlayerPositionChanged;
                _player.Events.PlayerEncounteredError += EventsPlayerEncounteredError;
                _player.CustomRenderer.SetCallback(bmp => bmp.Dispose());
                _player.CustomRenderer.SetFormat(new BitmapFormat(100, 100, ChromaType.RV24));

                _player.Play();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, LocRm.GetString("Error"));
            }
        }
Beispiel #14
0
        public PlayerWindow(IMediaFileIterator files, PlayerOptions options)
        {
            mOptions       = options;
            mFiles         = files;
            mFilesIterator = mFiles.GetEnumerator();
            InitializeComponent();

            var playerPath = Application.StartupPath;

            mPlayerFactory    = new MediaPlayerFactory(playerPath);
            mPlayer           = mPlayerFactory.CreatePlayer <IDiskPlayer>();
            mPlayerController = new PlayerController(mPlayer, mPlayerFactory);

            mPlayer.Events.MediaEnded    += new EventHandler(Events_MediaEnded);
            mPlayer.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);
            mPlayer.Events.PlayerPaused  += new EventHandler(Events_PlayerPaused);
            mPlayer.Events.PlayerPlaying += new EventHandler(Events_PlayerPlaying);

            mPlayer.WindowHandle    = Handle;
            mPlayer.KeyInputEnabled = false;

            KeyDown += new KeyEventHandler(playerWindow_KeyDown);
        }
Beispiel #15
0
        private void button7_Click(object sender, EventArgs e)
        {
            run = true;
            Thread t = new Thread(() =>
            {

                int thisCount = countSave++;
                if (!string.IsNullOrEmpty(textBox1.Text))
                {
                    var factory = new MediaPlayerFactory();
                    var player = factory.CreatePlayer<IDiskPlayer>();

                    player.Events.PlayerPositionChanged += new EventHandler<MediaPlayerPositionChanged>(Events_PlayerPositionChanged);
                    player.Events.TimeChanged += new EventHandler<MediaPlayerTimeChanged>(Events_TimeChanged);
                    player.Events.MediaEnded += new EventHandler(Events_MediaEnded);
                    player.Events.PlayerStopped += new EventHandler(Events_PlayerStopped);

                    trackBar2.Value = player.Volume;

                    // string output = ":sout=file:abc.mp4";

                    // string output = ":sout=#transcode{vcodec=h264,vb=0,scale=0,acodec=mpga,ab=128,channels=2,samplerate=44100}:duplicate{dst=file{dst=abc.mp4}";//,dst=display}
                    // string output1 = ":demux=dump :demuxdump-file=output.mp4";

                    while (run)
                    {
                        try
                        {
                            string fileName = "data\\" + thisCount + "-" + DateTime.Now.ToLongTimeString();
                            string output = ":sout=#transcode{demux=dump}:duplicate{dst=file{dst=" + fileName + ".mp4},dst=rtp{sdp=rtsp://:42624/test},dst=http{mux=ffmpeg{mux=flv},dst=:48684/}}";//,dst=display} dst=rtp{sdp=rtsp://:8554/},dst=http{mux=ffmpeg{mux=flv},dst=:8080/}

                            var media = m_factory.CreateMedia<IMedia>(textBox1.Text, output);
                            media.Events.DurationChanged += new EventHandler<MediaDurationChange>(Events_DurationChanged);
                            media.Events.StateChanged += new EventHandler<MediaStateChange>(Events_StateChanged);
                            media.Events.ParsedChanged += new EventHandler<MediaParseChange>(Events_ParsedChanged);

                            player.Open(media);
                            media.Parse(true);

                            player.Play();

                            Thread.Sleep(60000);
                            player.Stop();
                        }
                        catch { }
                    }
                }
                else
                {
                    errorProvider1.SetError(textBox1, "Please select media path first !");
                }

            });

            t.Start();
        }
Beispiel #16
0
        private void TestVLC()
        {
            string url = cmbVLCURL.Text.Trim();
            if (url == string.Empty)
            {
                MessageBox.Show(LocRm.GetString("Validate_SelectCamera"), LocRm.GetString("Note"));
                return;
            }

            btnGetStreamSize.Enabled = false;
            StopPlayer();
            try
            {
                _factory = new MediaPlayerFactory();
                _player = _factory.CreatePlayer<IVideoPlayer>();
                _media = _factory.CreateMedia<IMedia>(url, txtVLCArgs.Text);
                _player.Open(_media);
                _player.Mute = true;
                _player.Events.PlayerPositionChanged += EventsPlayerPositionChanged;
                _player.Events.PlayerEncounteredError += EventsPlayerEncounteredError;
                _player.CustomRenderer.SetCallback(bmp => bmp.Dispose());
                _player.CustomRenderer.SetFormat(new BitmapFormat(100, 100, ChromaType.RV24));

                _player.Play();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, LocRm.GetString("Error"));
            }
        }
Beispiel #17
0
        protected override void DoBackgroundWork()
        {
            try
            {
                frameEncodeInterval = 1000 / this.cameraSpec.vlc_transcode_fps;
                w = this.cameraSpec.h264_video_width;
                h = this.cameraSpec.h264_video_height;
                if (w <= 0 || h <= 0)
                {
                    w = h = 0;
                }

                IVideoPlayer player = null;

                while (!Exit)
                {
                    try
                    {
                        frameNumber             = 0;
                        lastFrameEncoded        = 0;
                        nextFrameEncodeTime     = 0;
                        lastTimestampUpdateTime = -1;
                        frameTimer.Start();
                        IMediaPlayerFactory factory = new MediaPlayerFactory();
                        player = factory.CreatePlayer <IVideoPlayer>();
                        player.Events.TimeChanged += new EventHandler <Declarations.Events.MediaPlayerTimeChanged>(Events_TimeChanged);
                        int      b    = cameraSpec.vlc_transcode_buffer_time;
                        string[] args = new string[] { ":rtsp-caching=" + b, ":realrtsp-caching=" + b, ":network-caching=" + b, ":udp-caching=" + b, ":volume=0", cameraSpec.wanscamCompatibilityMode ? ":demux=h264" : "", cameraSpec.wanscamCompatibilityMode ? ":h264-fps=" + cameraSpec.wanscamFps : "" };
                        string   url  = cameraSpec.imageryUrl;
                        if (cameraSpec.wanscamCompatibilityMode)
                        {
                            url = "http://127.0.0.1:" + MJpegWrapper.cfg.webport + "/" + cameraSpec.id + ".wanscamstream";
                        }
                        IMedia media = factory.CreateMedia <IMedia>(url, args);
                        memRender = player.CustomRenderer2;
                        //memRender.SetExceptionHandler(ExHandler);
                        memRender.SetCallback(delegate(Bitmap frame)
                        {
                            // We won't consume the bitmap here.  For efficiency's sake under light load, we will only encode the bitmap as jpeg when it is requested by a client.
                            frameNumber++;
                            if (!player.Mute)
                            {
                                player.ToggleMute();
                            }
                            if (frameTimer.ElapsedMilliseconds >= nextFrameEncodeTime)
                            {
                                EventWaitHandle oldWaitHandle = newFrameWaitHandle;
                                newFrameWaitHandle            = new EventWaitHandle(false, EventResetMode.ManualReset);
                                oldWaitHandle.Set();
                            }
                            //long time = frameCounter.ElapsedMilliseconds;
                            //if (time >= nextFrameEncodeTime)
                            //{
                            //    lastFrame = ImageConverter.GetJpegBytes(frame);
                            //    nextFrameEncodeTime = time + frameEncodeInterval;
                            //}
                            //latestBitmap = new Bitmap(frame);  // frame.Clone() actually doesn't copy the data and exceptions get thrown
                        });
                        memRender.SetFormat(new BitmapFormat(w, h, ChromaType.RV24));
                        //memRender.SetFormatSetupCallback(formatSetupCallback);
                        player.Open(media);
                        player.Play();
                        if (w == 0)
                        {
                            // Need to auto-detect video size.
                            while (!Exit)
                            {
                                Thread.Sleep(50);
                                Size s = player.GetVideoSize(0);
                                if (s.Width > 0 && s.Height > 0)
                                {
                                    lock (MJpegWrapper.cfg)
                                    {
                                        w = this.cameraSpec.h264_video_width = (ushort)s.Width;
                                        h = this.cameraSpec.h264_video_height = (ushort)s.Height;
                                        MJpegWrapper.cfg.Save(Globals.ConfigFilePath);
                                    }
                                    throw new Exception("Restart");
                                }
                            }
                        }
                        else
                        {
                            while (!Exit)
                            {
                                Thread.Sleep(50);
                            }
                        }
                    }
                    catch (ThreadAbortException ex)
                    {
                        throw ex;
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message != "Restart")
                        {
                            Logger.Debug(ex);
                            int waitedTimes = 0;
                            while (!Exit && waitedTimes++ < 100)
                            {
                                Thread.Sleep(50);
                            }
                        }
                    }
                    finally
                    {
                        frameTimer.Stop();
                        frameTimer.Reset();
                        if (player != null)
                        {
                            player.Stop();
                        }
                        newFrameWaitHandle.Set();
                    }
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                Logger.Debug(ex);
            }
            newFrameWaitHandle.Set();
        }
Beispiel #18
0
        private void ConstructPlayer(string outputString)
        {
            IMediaPlayerFactory factory = new MediaPlayerFactory();

            IMedia media = factory.CreateMedia<IMedia>("screen://", outputString);
            player = factory.CreatePlayer<IPlayer>();
            player.Open(media);
        }
Beispiel #19
0
        public static void vlcSave(string localPath, string rootPath)
        {
            //Thread t = new Thread(() =>
            //{
            if (!Directory.Exists(rootPath + "\\data1"))
            {
                Directory.CreateDirectory(rootPath + "\\data1");//dst=http{mux=ffmpeg{mux=flv},dst=:8080/}
            }
                if (!Directory.Exists(localPath + "\\data2"))
                {
                    Directory.CreateDirectory(localPath + "\\data2");//dst=http{mux=ffmpeg{mux=flv},dst=:8080/}
                }
                File.WriteAllText(rootPath + "ff", "");

                //string output = ":sout=file:" + localPath + "abc.mp4";

                // string output = ":sout=#transcode{vcodec=h264,vb=0,scale=0,acodec=mpga,ab=128,channels=2,samplerate=44100}:duplicate{dst=file{dst=abc.mp4}";//,dst=display}
                // string output = ":demux=dump :demuxdump-file=output.mp4";
                try
                {
                    File.WriteAllText(rootPath + "b1", "");

                    var factory = new MediaPlayerFactory();
                    File.WriteAllText(rootPath + "b2", "");

                    var player = factory.CreatePlayer<IDiskPlayer>();

                    File.WriteAllText(rootPath + "b3", "");

                    string fileName = localPath + "abc";
                    //string fileName = localPath + DateTime.Now.ToLongTimeString();
                    //string fileName = localPath + "\\" + DateTime.Now.ToLongTimeString();
                    //string fileName =  DateTime.Now.ToLongTimeString();
                    //string output = ":sout=#transcode{demux=dump}:duplicate{dst=file{dst=" + fileName + ".mp4},dst=rtp{sdp=rtsp://:8554/}}";
                    //string output = ":sout=#transcode{demux=dump,channels=1}:duplicate{dst=file{dst=" + fileName + ".mp4},dst=rtp{sdp=rtsp://:8554/}}";
                    //string output = ":sout=#transcode{demux=dump,channels=1}:duplicate{dst=file{dst=" + fileName + ".mp4},dst=rtp{sdp=rtsp://:8554/}}";
                    string output = ":sout=#transcode{demux=dump,channels=1}:duplicate{dst=file{dst=" + fileName + ".mp4}}";

                    var media = factory.CreateMedia<IMedia>(rootPath + "_5_19_01.mp4", output);
                    //rtsp://178.218.212.102:1935/live/Stream2
                    //delay 15~25 sec
                    //have 4 streams 0:A 1:V 2:A 3:V
                    //channnels=0: rec->Audio stream->Audio
                    //channnels=1: rec->Audio+Video stream->Audio+Video
                    //channnels=4: rec->Audio stream->Audio+Video

                    player.Open(media);
                    media.Parse(true);

                    player.Play();

                    Thread.Sleep(50000);
                    player.Stop();
                    File.WriteAllText("fin", "");
                }
                catch (Exception ex){
                    File.WriteAllText(rootPath + "ex" + ex.Message, "");
                }
            //});

            //t.Start();
        }