VideoLan.Interop a .Net libvlc 0.9.x wrapper

This forum is about all development around libVLC.
am70
Blank Cone
Blank Cone
Posts: 12
Joined: 25 Apr 2009 06:02

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby am70 » 25 Apr 2009 18:01

Hi Kairos

Thanks for the reply. I know I can do what you say to display multiple players on screen. How would I stream each of those players' video to a different IP address?

Andrew

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 25 Apr 2009 18:38

In that case VlcMedia has a function AddOption(string)

Instead of placing the command line options that streams the video to an ip address in the VideoLanClient constructor, you should use the VlcMedia.Addption(string option) function to do it. To make it simple, any command line option you pass in through the VideoLanConstructor is used on every file you play. While any command line option you add to a VlcMedia object through the AddOption function is used just for that file. The only down side is that to acomplish what you want you are going to have to add the command line option to point to the correct ip address every time you create VlcMedia object.

am70
Blank Cone
Blank Cone
Posts: 12
Joined: 25 Apr 2009 06:02

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby am70 » 26 Apr 2009 03:55

Hi Kairos

I have tried what you suggest, but anything I pass to AddOption() seems to be ignored:

Code: Select all

string[] opts = { @"--sout=#transcode{vcodec=mp2v,vb=8000,scale=1}", }; Vlc = new VideoLanClient(@"c:\blah\", opts); VlcPlayer1 = Vlc.NewMediaPlayer(System.IntPtr.Zero); VlcMedia desc1 = Vlc.NewMedia(@"1.avi"); desc1.AddOption(@":duplicate{dst=rtp{dst=127.0.0.1,mux=ts,port=1234}}"); VlcPlayer1.Load(desc1); desc1.Dispose(); VlcPlayer2 = Vlc.NewMediaPlayer(System.IntPtr.Zero); VlcMedia desc2 = Vlc.NewMedia(@"2.avi"); desc2.AddOption(@":duplicate{dst=rtp{dst=127.0.0.1,mux=ts,port=1235}}"); VlcPlayer2.Load(desc2); desc2.Dispose(); VlcPlayer1.Play(); VlcPlayer2.Play();
Is my command-line syntax for AddOption() wrong? It works perfectly if I specify the entire options string for the VideoLanClient() constructor (but only for 1 VlcPlayer() instance, of course).

Andrew

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 26 Apr 2009 04:07

i think each option needs to start with -- not a : like you are using.

am70
Blank Cone
Blank Cone
Posts: 12
Joined: 25 Apr 2009 06:02

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby am70 » 26 Apr 2009 04:18

I have tried --, : and nothing at all. I can't get it to recognise the option regardless of what I use. Very frustrating!

If I leave the VlcClient() options empty, and try passing the entire options string through AddOption(), it's also ignored.

Could this be a wrapper bug, or a libvlc peculiarity?

Andrew

mohamnag
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Mar 2009 16:04

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby mohamnag » 26 Apr 2009 06:59

Hi Kairos,
I'm so glad that you are back on the development. I have tried to work with VideoLan.Interop in WPF using a windows forms host to create a panel and pass its handle to VideoLan.Interop.
Every thing works fine, however the memory usage is nearly twice the VLC.
I had tested it with Windows forms application and at first I got the same results but after some workarounds realized that having some references (I think Linq) makes the problem. removing these references solved the problem in windows forms application but in WPF the problem exists.
Would you try solve this?
When the problem is related to windows forms host, can you integrate the VideoLan.Interop with some native WPF elements to display the video output?
I have seen some where some thing similar done with VideoRenderer. watch this thread up: VLC Element for WPF.
However it works with old vlc not 9.x

MidnightCoder
Blank Cone
Blank Cone
Posts: 82
Joined: 08 Aug 2008 06:04

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby MidnightCoder » 26 Apr 2009 11:41

Hi guys, I've been away for a while on what you might call the opposite of a vacation (aka excessive work). I want to take care of the bugs first and stabilize the wrapper before adding new features. Can you summarize what the current bugs are?
Nice to have you back. Here is a bug I found:
1. While the player is playing a video file, this.Text = VlcPlayer.Video.AspectRatio; ----> Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

mohamnag
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Mar 2009 16:04

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby mohamnag » 26 Apr 2009 16:20

I wanted to ask another thing. VlcMedia.AddOption works if it is call after loading it into VlcPlayer?

Thanks for your great work Kairos

elund
Blank Cone
Blank Cone
Posts: 18
Joined: 22 Jan 2009 10:42

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby elund » 26 Apr 2009 21:34

Hi guys, I've been away for a while on what you might call the opposite of a vacation (aka excessive work). I want to take care of the bugs first and stabilize the wrapper before adding new features. Can you summarize what the current bugs are?
Hi Kairos!

Welcome back :-)

What are you comments to my issue below.
I still experience this wrapper - and the one made by Marx - as unstable.
They regularly stops playing videos (my application stops responding).
I have not been able to fix this issue yet, but when it happens it is always after a call to Play().

Best regards, Elund
(Correct me if im wrong) I believe the problem is caused by the delay due to bindings. for example, if you call play, the vlc will actually play 1 seconds later(as i said, example). you will experience issue when you issue multiple command within short period of time. AFAIK, there are no good solution for this. only workarounds. one workaround that i know of is by adding a delay before any command can be issue consequently.
Best regards, Elund

am70
Blank Cone
Blank Cone
Posts: 12
Joined: 25 Apr 2009 06:02

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby am70 » 28 Apr 2009 04:28

I have figured out my previous problem, and now have a new one :)

I got AddOption() to work by initialising VlcClient with no options at all, and loading the entire set of options into each individual media source using AddOption().

This appears to work, and I can now stream different files to different IP addresses/ports.

HOWEVER, I have now run into another problem which on the surface seems simple to solve. I'm sure I'm just missing something obvious.

When I specify a file for each player instance, everything works fine. When I specify a DirectShow capture device (my application requires the live streaming of 4 cameras), it always picks the default capture device (being the first one DirectShow returns).

I have tried every variation of the syntax that I'm aware of, but cannot stream from anything other than the default device. So I have something like this:

Code: Select all

string[] opts = { @"", }; Vlc = new VideoLanClient(@"c:\blah\", opts); VlcPlayer1 = Vlc.NewMediaPlayer(System.IntPtr.Zero); VlcMedia desc1 = Vlc.NewMedia(@"dshow:// vdev='BT878 Capture 3'); desc1.AddOption(@":sout=#transcode{vcodec=mp2v,vb=8000,scale=1}:duplicate{dst=rtp{dst=192.168.0.1,mux=ts,port=1000}}"); VlcPlayer1.Load(desc1); desc1.Dispose(); VlcPlayer1.Play();
This will stream from Capture device 0 (being the first in the list and therefore the default), rather than device 3, which is what I want.

I have tried many variations of the MRL, with and without quotes around the device name, vdev=, dshow-vdev=, etc.

Can anyone suggest an MRL which will actually work??

Andrew

nicko
New Cone
New Cone
Posts: 6
Joined: 02 Apr 2009 10:27

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby nicko » 28 Apr 2009 10:34

Hi guys, I've been away for a while on what you might call the opposite of a vacation (aka excessive work). I want to take care of the bugs first and stabilize the wrapper before adding new features. Can you summarize what the current bugs are?
You're a good man(?) Kairos... and I really want to use this wrapper as a part of the project I'm working on, but currently it's a little unstable when you call Stop() or Dispose() sometimes, the method simply doesn't return.
Unfortunately I can't give you code to recreate this error reliably as it only seems to happen after 4 or 5 plays (but I have seen it happen on the first one before) which suggests to me there may be a race condition in there somewhere. It also seems to happen more reliably when playing a video stream rather than media from local storage. Sorry I can't be of more help. There are other discussions about this issue (from other wrappers too, which suggests it's something in VLC itself but may be able to be worked around). You can make it happen with the PublicENEMY example if u hack it to take a stream MRL, the particular type of streaming I'm seeing it happen with is UDP, with an MPEG-TS stream containing mpeg4-audio and mpeg-4 video, but I assume it can happen with other types.

viewtopic.php?f=2&t=51184

viewtopic.php?f=32&t=47385&start=60#p167349

Other than that it's been pretty good for me, looking forward to testing a new version!

Kind Regards,
Nick

am70
Blank Cone
Blank Cone
Posts: 12
Joined: 25 Apr 2009 06:02

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby am70 » 28 Apr 2009 11:27

Solved my problem. In case anyone else runs into it, this is the working code to specify a DirectShow capture device per player instance:

Code: Select all

VlcPlayer1 = Vlc.NewMediaPlayer(System.IntPtr.Zero); VlcMedia desc1 = Vlc.NewMedia(@"dshow://"); desc1.AddOption(@":dshow-vdev=BT878 Capture 1"); desc1.AddOption(@":sout=#transcode{vcodec=mp2v,vb=8000,scale=1}:duplicate{dst=rtp{dst=192.168.0.1,mux=ts,port=1000}}"); VlcPlayer1.Load(desc1);
The trick is to put the device name into a separate AddOption() call.

Andrew

am70
Blank Cone
Blank Cone
Posts: 12
Joined: 25 Apr 2009 06:02

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby am70 » 28 Apr 2009 11:30

Hi Kairos

I know you said you want to fix the bugs first, but I'd be remiss if I didn't mention that my number 1 feature request is native WPF support. I'm using VLC Renderer at the moment which works well, but does not support multiple player instances.

Andrew

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 05 May 2009 18:59

@Elund, publicENEMY is correct. VLC is threaded and runs asynchronously to your program. So even though you call a function that does not mean the function exited on vlc. I too suffer from this problem in my app. For me it mainly happens when seeking. We solved it by placing a time delay on successive calls. So if the app receives a function call within x milliseconds of the last call then we wait and then execute the call.

@Andrew, I'm glad you got AddOption to work. I couldn't figure what could be wrong with it. WPF is still a goal, but whats the point of supporting WPF if the player is buggy and has memory leaks.

nicko, I'll see if I can figure out your problem. I've never really tested it on video streams, so I'll give that a shot.

Right now I'm tracking down a memory leak that's been reported by a few people. I'll post an update when that's fixed to see if it accidentally solves other problems.

zilched
New Cone
New Cone
Posts: 1
Joined: 11 Jan 2009 23:29

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby zilched » 07 May 2009 15:36

I'm trying to play a stream through this wrapper using the following

Code: Select all

VlcMedia desc = Vlc.NewMedia(filename); VlcPlayer.Load(desc); desc.Dispose(); VlcPlayer.Play();
if I pass the actual stream URL, the stream plays. ie the following works:

Code: Select all

string filename = "mms://wmlive-acl.bbc.co.uk/wms/bbc_ami/radio1/radio1_bb_live_eq1_sl0?BBC-UID=945a3082dec341e5dda25cfd113eaa3e1c94c2be00d0e1f4a42fa936cf8ec007&SSO2-UID="
but if I pass a playlist file the stream doesn't play. The same is true for winamp m3u files.

Code: Select all

string filename=http://www.bbc.co.uk/radio1/wm_asx/aod/radio1.asx
Both links play in a normal VLC instance.

What do I need to prepare the stream for playback?

Cheers

Lupu
New Cone
New Cone
Posts: 3
Joined: 08 Apr 2009 03:24

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Lupu » 10 May 2009 13:14

Should "VideoLan.Interop" work with latest vlc sources obtained with git clone git://git.videolan.org/vlc.git ?
( i think ver. is "VLC 1.0.0 - Release Candidate 1" )
thx

It seems that a freq. reported problem was been recently fixed : vlc freezes when playing and stoping the playback a couple o times
http://git.videolan.org/?p=vlc.git;a=co ... 6efbc42055

Beardless2
Cone that earned his stripes
Cone that earned his stripes
Posts: 125
Joined: 02 Feb 2007 09:53

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Beardless2 » 14 May 2009 12:08

Should "VideoLan.Interop" work with latest vlc sources obtained with git clone git://git.videolan.org/vlc.git ?
( i think ver. is "VLC 1.0.0 - Release Candidate 1" )
thx

It seems that a freq. reported problem was been recently fixed : vlc freezes when playing and stoping the playback a couple o times
http://git.videolan.org/?p=vlc.git;a=co ... 6efbc42055
are you sure? i still get this even with the latest nightly build

nicko
New Cone
New Cone
Posts: 6
Joined: 02 Apr 2009 10:27

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby nicko » 14 May 2009 12:10

are you sure? i still get this even with the latest nightly build
ditto

Beardless2
Cone that earned his stripes
Cone that earned his stripes
Posts: 125
Joined: 02 Feb 2007 09:53

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Beardless2 » 20 May 2009 17:44

i think i might have a workaround for the stop() dead lock.

In my app, i have a windows form, then i place a panel (PanelA) onto that form, then place another panel (PanelB) onto PanelA. Then i set the VLC video output to be onto the handle of PanelB and start playing.

Now, before you stop() the video, hide PanelA by settings its parent to be nil, then call stop() and then reparent PanelA back onto the form.

Does this help anyone else?

cmont5150
New Cone
New Cone
Posts: 1
Joined: 21 May 2009 19:52

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby cmont5150 » 21 May 2009 19:58

I truly appreciate the wrapper. I am a newbie to developing for VLC and i have a specific need and I would like to see if your wrapper will do what I need...

I am usng VLC to transcode incoming mpeg 2 video coming from one of 4 multicast streams to either H.264 or mpeg-4 and streaming the transcoded video to another url. I would also like to control the encoding rate in real time. Is this something that I can do with your wrapper (or even with libvlc)? Thanks for your help!!

Chris

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 05 Jun 2009 23:13

Just for an update. I'm unable to track down the important memory leaks and bugs in the current version. I suspect many of the problems are from VLC 0.9 itself. For that reason, I'm abandoning the 0.9 version and moving to 1.0. I'm working on updating the code to work with 1.0. There is new functionality, new events, and If I find the time I'll finish the VLM stuff too.

I'm also considering removing the MediaListPlayer from this wrapper. The MediaListPlayer has never worked and I've heard very few complaints about it. IMO the playlist functionality should be written by you guys, not vlc. That is why I've never really concentrated on the MediaList, MediaLibrary, or MediaDiscoverer classes.

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 05 Jun 2009 23:16

Oh, and as a reply to peoples questions on streaming... the answer is I really don't know. I've never tried to use my wrapper for streaming purposes. If you are having problems figuring out the command line options, it might be better to ask those questions in a more general forum.

sonamsingh19
New Cone
New Cone
Posts: 1
Joined: 19 Jun 2009 19:59

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby sonamsingh19 » 19 Jun 2009 20:15

Hiii guys,I don't know how many of u have got around this issue.
In ym case
I have a tabcontrol
the main tab/front window has a windowsformshost with a child as panel.the second tabitem is a list of items that i can use to playt things from.
In the constructor of my windows ,i set the handle of vlcmediaplayer class before vlcmediaplayer class is used inside another library to load and then play songs.
Now the issue,
when i play the video first time from second tab item ,its going cool.if i switch to the list of videos on second tab item again after seeing video and play any item,
I get a blue screen of death.
I handled a HadnleDestroyed even also with a debug.assert statement to see if its destroyed but i think its not as its not called.
FYI,Between any succesive calls i have set almost 800 millisecnds time explictily.
Also,
I keep things like windowsformshost,videopanel,VideoLanClient instance and VlcMediaPlayer instance within GC.KeepAlive() to prevent premature cleanup of these.

I have used VideoLanClient as VideoLanClient vlc=new VideoLanClient();
I am using plugins fro vlc 0.9.9.
Any idea whats causing that BSOD.Plz help me. .Its now occuring faster .earlier it was occuring after 10-12 video plays..
But u can say thats my problem..
Although,I haven't tried,ut i think it BSOD won't be there in Windows forms.
windowsformshost has something to do probably..Just my brain...
Whatever u feel,plz say,it might solve my problem.

socialjazz
Blank Cone
Blank Cone
Posts: 17
Joined: 19 May 2009 09:14

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby socialjazz » 20 Jun 2009 08:11

I'm trying to play a stream through this wrapper using the following

Code: Select all

VlcMedia desc = Vlc.NewMedia(filename); VlcPlayer.Load(desc); desc.Dispose(); VlcPlayer.Play();
if I pass the actual stream URL, the stream plays. ie the following works:

Code: Select all

string filename = "mms://wmlive-acl.bbc.co.uk/wms/bbc_ami/radio1/radio1_bb_live_eq1_sl0?BBC-UID=945a3082dec341e5dda25cfd113eaa3e1c94c2be00d0e1f4a42fa936cf8ec007&SSO2-UID="
but if I pass a playlist file the stream doesn't play. The same is true for winamp m3u files.

Code: Select all

string filename=http://www.bbc.co.uk/radio1/wm_asx/aod/radio1.asx
Both links play in a normal VLC instance.

What do I need to prepare the stream for playback?

Cheers

have anyone manage to solve this problem yet? I like this wrapper alot and it also works on 1.0.0
The only thing thatis bugging me is the inability to play online playlist

socialjazz
Blank Cone
Blank Cone
Posts: 17
Joined: 19 May 2009 09:14

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby socialjazz » 20 Jun 2009 08:14

Hiii guys,I don't know how many of u have got around this issue.
In ym case
I have a tabcontrol
the main tab/front window has a windowsformshost with a child as panel.the second tabitem is a list of items that i can use to playt things from.
In the constructor of my windows ,i set the handle of vlcmediaplayer class before vlcmediaplayer class is used inside another library to load and then play songs.
Now the issue,
when i play the video first time from second tab item ,its going cool.if i switch to the list of videos on second tab item again after seeing video and play any item,
I get a blue screen of death.
I handled a HadnleDestroyed even also with a debug.assert statement to see if its destroyed but i think its not as its not called.
FYI,Between any succesive calls i have set almost 800 millisecnds time explictily.
Also,
I keep things like windowsformshost,videopanel,VideoLanClient instance and VlcMediaPlayer instance within GC.KeepAlive() to prevent premature cleanup of these.

I have used VideoLanClient as VideoLanClient vlc=new VideoLanClient();
I am using plugins fro vlc 0.9.9.
Any idea whats causing that BSOD.Plz help me. .Its now occuring faster .earlier it was occuring after 10-12 video plays..
But u can say thats my problem..
Although,I haven't tried,ut i think it BSOD won't be there in Windows forms.
windowsformshost has something to do probably..Just my brain...
Whatever u feel,plz say,it might solve my problem.
use 1.0.0RC3 instead, and the BSOD will be gone


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 2 guests