Page 1 of 1

Cannot stream from device

Posted: 15 Oct 2014 10:15
by buloheart
I've been trying to use nVLC (more info here: http://www.codeproject.com/Articles/109639/nVLC) to stream video directly from a camera as it is captured. Below is the code that doesn't stream anything (the commented libvlc calls following any line of code is what nVLC calls in turn)

Code: Select all

/* Not working */ Declarations.IMediaPlayerFactory factory = new Implementation.MediaPlayerFactory(); //m_hMediaLib = LibVlcMethods.libvlc_new(args.Length, args); {"-I", "dumy", "--ignore-config", "--no-osd", "--disable-screensaver", "--plugin-path=./plugins"} //LibVlcMethods.libvlc_log_set(m_instance, hCallback, IntPtr.Zero); string sout = ":sout=#rtp{dst=127.0.0.1,port=5004,ttl=40,mux=ts}"; media = factory.CreateMedia(@"dshow://", WebCams[InputDeviceSelection.SelectedIndex].ToString(), sout); //m_hMedia = LibVlcMethods.libvlc_media_new_location(m_hMediaLib, m_path.ToUtf8()); "dshow://" //LibVlcMethods.libvlc_media_add_option(m_hMedia, item.ToUtf8()); "[0] Sony Visual Communication Camera: SOME_GUID" //LibVlcMethods.libvlc_media_add_option(m_hMedia, item.ToUtf8()); ":sout=#rtp{dst=127.0.0.1,port=5004,ttl=40,mux=ts}" renderPlayer = factory.CreatePlayer(); //LibVlcMethods.libvlc_media_player_new(m_hMediaLib); //LibVlcMethods.libvlc_media_player_retain(m_hMediaPlayer); renderPlayer.Open(media); //LibVlcMethods.libvlc_media_player_set_media(m_hMediaPlayer, ((INativePointer)media).Pointer); renderPlayer.Play(); //LibVlcMethods.libvlc_media_player_play(m_hMediaPlayer);
Now the below two works, but one streams from file, the other displays from camera

Code: Select all

/* Working streaming file */ var input = @"C:\Users\buloheart\Downloads\SomeVideo.mkv"; Declarations.IMediaPlayerFactory factory = new Implementation.MediaPlayerFactory(); //m_hMediaLib = LibVlcMethods.libvlc_new(args.Length, args); {"-I", "dumy", "--ignore-config", "--no-osd", "--disable-screensaver", "--plugin-path=./plugins"} //LibVlcMethods.libvlc_log_set(m_instance, hCallback, IntPtr.Zero); string sout = ":sout=#rtp{dst=127.0.0.1,port=5004,ttl=40,mux=ts}"; media = factory.CreateMedia(input, sout); //m_hMedia = LibVlcMethods.libvlc_media_new_path(m_hMediaLib, m_path.ToUtf8()); //LibVlcMethods.libvlc_media_add_option(m_hMedia, item.ToUtf8()); ":sout=#rtp{dst=127.0.0.1,port=5004,ttl=40,mux=ts}" renderPlayer = factory.CreatePlayer(); //LibVlcMethods.libvlc_media_player_new(m_hMediaLib); //LibVlcMethods.libvlc_media_player_retain(m_hMediaPlayer); renderPlayer.Open(media); //LibVlcMethods.libvlc_media_player_set_media(m_hMediaPlayer, ((INativePointer)media).Pointer); renderPlayer.Play(); //LibVlcMethods.libvlc_media_player_play(m_hMediaPlayer); /**/

Code: Select all

/* Working displaying from camera */ Declarations.IMediaPlayerFactory factory = new Implementation.MediaPlayerFactory(); //m_hMediaLib = LibVlcMethods.libvlc_new(args.Length, args); {"-I", "dumy", "--ignore-config", "--no-osd", "--disable-screensaver", "--plugin-path=./plugins"} //LibVlcMethods.libvlc_log_set(m_instance, hCallback, IntPtr.Zero); media = factory.CreateMedia(@"dshow://", WebCams[InputDeviceSelection.SelectedIndex].ToString()); //m_hMedia = LibVlcMethods.libvlc_media_new_location(m_hMediaLib, m_path.ToUtf8()); "dshow://" //LibVlcMethods.libvlc_media_add_option(m_hMedia, item.ToUtf8()); "[0] Sony Visual Communication Camera: SOME_GUID" renderPlayer = factory.CreatePlayer(); //LibVlcMethods.libvlc_media_player_new(m_hMediaLib); //LibVlcMethods.libvlc_media_player_retain(m_hMediaPlayer); renderPlayer.WindowHandle = PreviewPictureBox.Handle; //LibVlcMethods.libvlc_media_player_set_hwnd(m_hMediaPlayer, value); renderPlayer.Open(media); //LibVlcMethods.libvlc_media_player_set_media(m_hMediaPlayer, ((INativePointer)media).Pointer); renderPlayer.Play(); //LibVlcMethods.libvlc_media_player_play(m_hMediaPlayer); /**/
Can anyone help me figure out why the first one which tries to stream directly from webcam is not working? What is missing/wrong?

Thanks...

Re: Cannot stream from device

Posted: 17 Oct 2014 16:18
by buloheart
I'm uploading the below version as well as it would be easier to follow for many people:

Code: Select all

/* Below shows webcam on the picturebox */ var args = new string[] { "-I", "dumy", "--ignore-config", "--no-osd", "--disable-screensaver", "--plugin-path=./plugins" }; var m_path = "dshow://"; var m_hMediaLib = LibVlcWrapper.LibVlcMethods.libvlc_new(args.Length, args); var m_hMedia = LibVlcWrapper.LibVlcMethods.libvlc_media_new_location(m_hMediaLib, ToUtf8(m_path)); var m_hMediaPlayer = LibVlcWrapper.LibVlcMethods.libvlc_media_player_new_from_media(m_hMedia); var item = "[0] Sony Visual Communication Camera: SOME_GUID"; LibVlcWrapper.LibVlcMethods.libvlc_media_add_option(m_hMedia, ToUtf8(item)); LibVlcWrapper.LibVlcMethods.libvlc_media_player_set_hwnd(m_hMediaPlayer, PreviewPictureBox.Handle); LibVlcWrapper.LibVlcMethods.libvlc_media_player_play(m_hMediaPlayer); /**/ /* Below streams video file */ var args = new string[] { "-I", "dumy", "--ignore-config", "--no-osd", "--disable-screensaver", "--plugin-path=./plugins" }; var m_path = @"C:\Users\buloheart\Downloads\silvvvv.mkv"; var m_hMediaLib = LibVlcWrapper.LibVlcMethods.libvlc_new(args.Length, args); var m_hMedia = LibVlcWrapper.LibVlcMethods.libvlc_media_new_path(m_hMediaLib, ToUtf8(m_path)); var m_hMediaPlayer = LibVlcWrapper.LibVlcMethods.libvlc_media_player_new_from_media(m_hMedia); var item = ":sout=#rtp{dst=127.0.0.1,port=5004,ttl=40,mux=ts}"; LibVlcWrapper.LibVlcMethods.libvlc_media_add_option(m_hMedia, ToUtf8(item)); LibVlcWrapper.LibVlcMethods.libvlc_media_player_play(m_hMediaPlayer); /**/ /* Below does NOT stream from webcam */ var args = new string[] {"-I", "dumy", "--ignore-config", "--no-osd", "--disable-screensaver", "--plugin-path=./plugins"}; var m_path = "dshow://"; var m_hMediaLib = LibVlcWrapper.LibVlcMethods.libvlc_new(args.Length, args); var m_hMedia = LibVlcWrapper.LibVlcMethods.libvlc_media_new_location(m_hMediaLib, ToUtf8(m_path)); var m_hMediaPlayer = LibVlcWrapper.LibVlcMethods.libvlc_media_player_new_from_media(m_hMedia); var item = "[0] Sony Visual Communication Camera: SOME_GUID"; LibVlcWrapper.LibVlcMethods.libvlc_media_add_option(m_hMedia, ToUtf8(item)); item = ":sout=#rtp{dst=127.0.0.1,port=5004,ttl=40,mux=ts}"; LibVlcWrapper.LibVlcMethods.libvlc_media_add_option(m_hMedia, ToUtf8(item)); LibVlcWrapper.LibVlcMethods.libvlc_media_player_play(m_hMediaPlayer); /**/

Re: Cannot stream from device

Posted: 10 Dec 2014 15:13
by Jean-Baptiste Kempf
Without logs, it's hard.