<div dir="ltr">Hi:<div><br></div><div style>I am a newbee for vlc developing, now I want to do such thing in my corrent project:</div><div style><br></div><div style>a windows application, which can:</div><div style>1. Show living show from an directshow usb device on screen forever</div>
<div style>2. click a button to start to record the video into a mp4 file</div><div style>3. click another button to stop recording the video, but the living show should always there</div><div style><br></div><div style>to make it work, I created two VLC media player instances, one if for living show on screen, the other is for recording into file, copy some code here:</div>
<div style><br></div><div style>MyVLCPlayer.cs<br></div><div style><br></div><div style><div>        public MyVLCPlayer()</div><div>        {</div><div>            string[] arguments = { "-I", "dummy", "--ignore-config", "--no-video-title", @"--plugin-path=C:\Program Files (x86)\VideoLAN\VLC\plugins" };</div>
<div>            libvlc_instance_ = LibVlc.libvlc_new(arguments.Length, arguments);</div><div>            if (libvlc_instance_ != IntPtr.Zero)</div><div>            {</div><div>                libvlc_media_player_ = LibVlc.libvlc_media_player_new(libvlc_instance_);</div>
<div>            }</div><div>        }</div></div><div style><br></div><div style><div>        public void PlayDirectShow()</div><div>        {</div><div>            if (libvlc_instance_ != IntPtr.Zero)</div><div>            {</div>
<div>                IntPtr libvlc_media = LibVlc.libvlc_media_new_path(libvlc_instance_, @"dshow://");</div><div>                if (libvlc_media != IntPtr.Zero)</div><div>                {</div><div>                        string[] options = new string[]</div>
<div>                        {</div><div><span class="" style="white-space:pre">            </span>                    ":dshow-vdev=USB 2861 Device",</div><div>                            ":dshow-size=640*480",</div>
<div>                            </div><div>                        };</div><div>                        foreach (string option in options)</div><div>                        {</div><div>                            LibVlc.libvlc_media_add_option(libvlc_media, option);</div>
<div>                        }</div><div>                        if (libvlc_media_player_ != IntPtr.Zero)</div><div>                        {</div><div>                            LibVlc.libvlc_media_player_set_media(libvlc_media_player_, libvlc_media);</div>
<div>                        }</div><div>                        LibVlc.libvlc_media_release(libvlc_media);</div><div>                        LibVlc.libvlc_media_player_play(libvlc_media_player_);</div><div>                        //LibVlc.libvlc_media_player_pause(libvlc_media_player_);</div>
<div>                }</div><div>            }</div><div>        }</div><div><div>        public void RecordDirectShow(string filePath)</div><div>        {</div><div>            if (libvlc_instance_ != IntPtr.Zero)</div><div>
            {</div><div>                IntPtr libvlc_media = LibVlc.libvlc_media_new_path(libvlc_instance_, @"dshow://");</div><div>                if (libvlc_media != IntPtr.Zero)</div><div>                {</div>
<div>                    string[] options = new string[]</div><div>                        {</div><div><span class="" style="white-space:pre">          </span>                    ":dshow-vdev=USB 2861 Device",</div><div>
                            ":dshow-size=640*480",</div><div>                         </div><div>                            ":sout=#duplicate{dst=\'transcode{venc=x264{keyint=15,bframes=0},vcodec=h264,vb=400,scale=1,fps=25,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=file,mux=mp4,dst=" + filePath + "}\'}"</div>
<div>                        };</div><div>                    foreach (string option in options)</div><div>                    {</div><div>                        LibVlc.libvlc_media_add_option(libvlc_media, option);</div>
<div>                    }</div><div>                    if (libvlc_media_player_ != IntPtr.Zero)</div><div>                    {</div><div>                        LibVlc.libvlc_media_player_set_media(libvlc_media_player_, libvlc_media);</div>
<div>                    }</div><div>                    LibVlc.libvlc_media_release(libvlc_media);</div><div>                    LibVlc.libvlc_media_player_play(libvlc_media_player_);</div><div>                    //LibVlc.libvlc_media_player_pause(libvlc_media_player_);</div>
<div>                }</div><div>            }</div><div>        }</div></div><div><br></div><div style>MainWindow.xaml.cs<br></div><div style><br></div><div style><div>private MyVLCPlayer player;</div><div>        private MyVLCPlayer recorder;</div>
</div><div style><br></div><div style><div>        public MainWindow()</div><div>        {</div><div>            InitializeComponent();</div><div>....</div><div><div>player = new MyVLCPlayer();</div><div>            recorder = new MyVLCPlayer();</div>
</div><div>....</div><div><br></div><div>        }</div><div><br></div><div><div style> Then,</div><div style><br></div><div style>1. player. PlayDirectShow();</div></div><div style>2. recorder.RecordDirectShow(filepath);</div>
<div style>3. recorder.Stop();</div><div style><br></div><div style>the stop will never return!!</div><div style><br></div><div style>can someone tell me why?</div><div><br></div></div></div></div>