VideoLan.Interop a .Net libvlc 0.9.x wrapper

This forum is about all development around libVLC.
publicENEMY
Cone that earned his stripes
Cone that earned his stripes
Posts: 104
Joined: 14 May 2007 05:04
Location: Malaysia

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

Postby publicENEMY » 30 Mar 2009 03:43

Hi Youpi!

I would recommend you to managed your own playlist.
The author of VideoLan.Interop is actually doing the same: viewtopic.php?f=32&t=52021&p=176692&hil ... st#p176692.

With that said 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().
Unfortunately none of the authors seems to be active in this forum any longer.

So I am now using technologies like DirectX and Windows Media Player Control from Microsoft :-(
These components have significantly more CPU usage, but at least they are stable.

Best regards, Elund
regarding playlist.
Yes. This wrapper does not support the vlc playlist properly. i believe, it never will. this is because, it is highly recommended that the playlist is manually managed using c#. why? because you can do a lot of things easily in c# compared to the limited functionality of native playlist.

regarding video play issue.
(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.

Hope this helps.
Thanks.

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 » 02 Apr 2009 11:18

Hi All,

I'm trying to use this wrapper to produce a multicast stream, and am having great difficulty doing so. The main trouble being I can't find a way to make the wrapper take command line arguments.

For example, the first example on:
http://wiki.videolan.org/Documentation: ... e_Examples

vlc -vvv input_stream --sout '#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128,deinterlace}:rtp{mux=ts,dst=239.255.12.42,sdp=sap,name="TestStream"}

I've attempting to implement this as

Code: Select all

string[] options = { "--sout '#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128,deinterlace}:rtp{mux=ts,dst=239.255.12.42,sdp=sap,name=\"TestStream\"}'" }; client = new VideoLanClient(".", options); player = client.NewMediaPlayer(this.Handle); player.Load(client.NewMedia("c:\\myvideo.wmv")); player.Play();
But this only yields a black command prompt-ish window with the title "VLC media player version 0.9.8a" and the text "The command line options couldn't be loaded, check that they are valid"

Is there any way that command line options like I mentioned above can be used with this wrapper? I would prefer to do it this way as then I can enter the string above as a setting at run time so I can experiment with different settings without having to recompile the application.

I've had this working with the other wrapper (for 0.8.6) whose code is in this wiki, but that wrapper doesn't propagate events from VLC like this one, and I'd prefer to use VLC 0.9.x

Any help would be greatly appreciated.

Kind Regards,
Nick

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 » 02 Apr 2009 11:57

I may have rambled a little in my previous post. To boil down my question. Can somebody please explain why

Code: Select all

vlc -vvv c:\myvideo.wmv :sout=#transcode{vcodec=mp4v,vb=2048,scale=1,acodec=mp4a,ab=128,channels=2}:duplicate{dst=std{access=udp,mux=ts,dst=239.255.12.42:1234}}
On the command line produces different results to

Code: Select all

string[] options = { ":sout=#transcode{vcodec=mp4v,vb=2048,scale=1,acodec=mp4a,ab=128,channels=2}:duplicate{dst=std{access=udp,mux=ts,dst=239.255.12.42:1234}}", }; client = new VideoLanClient(".", options); player = client.NewMediaPlayer(this.Handle); player.Load(client.NewMedia("c:\\myvideo.wmv")); player.Play();
If I can work this out then that's all I need. Thanks in advance, and thanks for the wrapper!

-Nick

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 » 02 Apr 2009 12:07

OK, I RTFM'd (I had previously I just missed something) and realised the reason it wasn't working was because the options needed to be prefixed with a -- instead of a : because on the command line the : had a meaning that was lost in whatever way the wrapper invokes VLC. Thankyou for your time, sorry for the spam.

Regards,
Nick

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 » 17 Apr 2009 10:33

Hi All,

I've got VLC working with the VideoLan.Interop (meedios) wrapper, and everything works fine except I'm experiencing the oft-reported freezing problem when attempting to call Stop() on the VlcMediaPlayer. From the forums that I've read it appears as though this problem is not unique to the VideoLan.Interop wrapper and may be a problem within VideoLan itself.

Can someone clarify for me whether this is actually the case? do I need to just wait and hope that the problem will be fixed in VLC or is the problem in the wrapper. I downloaded VLC 0.99 recently in the hope it would fix the problem but it seems to exhibit exactly the same behaviour. The lock-up is definitely occurring inside the DLL code, whether that's due to an internal bug, or misuse by the myself or the VideoLan.Interop wrapper I'm not sure.

Any help would be greatly appreciated. Even a work-around would be nice.

PS. I'm not calling Stop() from an event handler thread as I know that will cause deadlock, I'm calling Stop from the same GUI thread that was used to create the player.

Cheers,
Nick

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 » 21 Apr 2009 10:32

Hi there,
it's a great wrapper for vlc. however when I use it in WPF using a windows forms host controller's child property to render the output. I get a very high memory consumption, nearly double of the same job in windows forms.
Has any one used this wrapper in WPF with better performance?

jstuardo
New Cone
New Cone
Posts: 8
Joined: 07 Apr 2009 16:07

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

Postby jstuardo » 24 Apr 2009 02:42

Hello....

I am trying VlcMediaPlayer sample but when I try to play a MPG file (a music video), it plays nothing! but when I run VLC Media Player 0.9.8a, that video plays correctly.

After I compiled VlcMediaPlayer, I copied all plugins directory together with libvlc.dll and libvlccore.dll into Debug directory of vlcMediaPlayer but nothing happens with this video.

Any help will be greatly appreciated, (I'm not using WPF)

Thanks
Jaime

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 » 24 Apr 2009 22:58

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?

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 07:29

Hi..

I am trying to stream multiple sources over the network to multiple targets. I'm aware of the fact that libvlc doesn't like multiple instances of itself, and suspect that VLM might be the answer.

I can see that there is code in VideoLan.Interop to support VLM. How complete is it?

Is there any chance some kind soul might post an example of using VLM with VideoLan.Interop..?

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 17:49

yes, you can only use 1 instance of libvlc (VideoLanClient class in the interop) but you can use multiple VlcMediaPlayers. For each simultaneous stream you want you would need another player. The VLM stuff is not working yet but many people here have done just fine streaming using the VlcMediaPlayer class.

Code: Select all

VideoLanClient client = new VideoLanClient(".", options); VlcMediaPlayer player1 = client.NewMediaPlayer(Form1.Handle); VlcMediaPlayer player2 = client.NewMediaPlayer(Form2.Handle);

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


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 7 guests