Cannot stream from device
Posted: 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)
Now the below two works, but one streams from file, the other displays from camera
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...
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);
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);
/**/
Thanks...