Cannot stream from device

This forum is about all development around libVLC.
buloheart
New Cone
New Cone
Posts: 2
Joined: 15 Oct 2014 10:02

Cannot stream from device

Postby buloheart » 15 Oct 2014 10:15

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...

buloheart
New Cone
New Cone
Posts: 2
Joined: 15 Oct 2014 10:02

Re: Cannot stream from device

Postby buloheart » 17 Oct 2014 16:18

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); /**/

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Cannot stream from device

Postby Jean-Baptiste Kempf » 10 Dec 2014 15:13

Without logs, it's hard.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 30 guests