Page 1 of 1

C# example

Posted: 02 Nov 2008 17:58
by szhdyn
Hi all, I spend all day but can't play video using .NET interface. I download code, build it and add dll to my test project. Add videolan control to my form.
Here is my code:

Code: Select all

namespace VlcTest { public partial class Form1 : Form { Timer timer; bool sizingNeeded; public Form1() { InitializeComponent(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.sizingNeeded = true; this.timer = new Timer(); this.timer.Interval = 500; this.timer.Tick += timer_Tick; this.timer.Start(); } void timer_Tick(object sender, EventArgs e) { if (this.sizingNeeded && (this.vlc.State == VLanControl.PlayerState.Playing)) { this.ClientSize = this.vlc.VideoSize; this.sizingNeeded = false; } } private void button1_Click(object sender, EventArgs e) { try { this.vlc.ClearPlayList(); this.vlc.AddAndPlay(@"C:\test.avi", String.Empty); this.vlc.Play(); } catch(Exception ex) { MessageBox.Show(ex.Message); } } private void vlc_Load(object sender, EventArgs e) { } } }
Run it but no video(
I read all related posts on the forum but didn't find solution. Is there any full example on C#?

Thanks,
Serhiy.

Re: C# example

Posted: 03 Nov 2008 06:46
by publicENEMY
there are a lot of api that can be use in c#. you have to specify what api are you using(source/origin). plus, did you get to compile the api? did you able to compile your program? did you copy vlc library file into your executable binary folder?

be more specific.

Re: C# example

Posted: 03 Nov 2008 09:52
by szhdyn
Hi.

Thank you for reply.

I use 0.8.6 API:
http://wiki.videolan.org/.Net_Interface_to_VLC

I compiled it and then add dll to my project. I add vlc library and even plugins folder to my debug folder
Project build seccessfully. I run it but no video playing.

I need working example on C# no matter which version of API it use.

Thanks,
Serhiy.

Re: C# example

Posted: 03 Nov 2008 11:11
by publicENEMY
I used to use Odyssey interop for videolan but that was a long time ago. in fact, i have used all kind of interop except Marx interop. they all have their weakness and strength and 5h1t, but i superstitiously believe without any scientific justification whatsoever that the recently found Videolan.Interop is superior.

Why?
1. it compatible with latest vlc(0.9.4)
2. wraps most of the exposed vlc newer api (no playlist though, few other 5h1t i forgot)

by the way, if you want to create a media player using videolan in .net environment, you can start here viewtopic.php?f=14&t=52021&p=169838#p169838

thanks.

Re: C# example

Posted: 03 Nov 2008 11:32
by szhdyn
Thank you very mych for that link.

The purpose of my application will be:

1) Retrieve video stream from network(for example it would be VLC Player in my local network)
2) Encrypt retrieved video stream.
3) Provide video streaming with encrypted data

Please advice best API for this purpose.

Thanks,
Serhiy.

Re: C# example

Posted: 03 Nov 2008 15:03
by publicENEMY
1. The sample i provide includes example on how to properly capture options. you can use this for streaming.
2. im not really sure bout encryption and decryption. maybe it is possible by using the plugins system. what im sure is, in order to create plugins, you have to be able to compile videolan. if you are using linux, this is not a problem. windows..., well..., you can try.
3. See 2.

The thing is, if you want to do encryption and decryption, there are few ways. two of em are by using ffmpeg(imho the correct way) and videolan plugins. the .net interop does not help. at all.

thanks.

Re: C# example

Posted: 03 Nov 2008 15:51
by szhdyn
I try that example and it works! Thanks!
Lets say I don't need encryption/decryption. Can I extend SamplePlayer to provide stream video to another ip:port?
(VLC 127.0.0.1:1234 <- SamplePlayer -> 192.168.xxx.xxx:xxxx <- AnotherCleint)

Thanks,
Serhiy.

Re: C# example

Posted: 03 Nov 2008 18:02
by publicENEMY
if you can serve stream using vlc command line, then you can use SamplePlayer to serve stream.

do tell me if you need an example. maybe tomorrow during lunch hour, ill fix it for you.

thanks.

Re: C# example

Posted: 03 Nov 2008 19:13
by szhdyn
It would be great if you send me example.
Thank you very much!

Re: C# example

Posted: 03 Nov 2008 19:51
by szhdyn
Also I interesting in saving stream video to hard disk.
How stream video is transported? UDP? How I can retrieve datagrams?

Thanks,
Serhiy.

Re: C# example

Posted: 04 Nov 2008 07:29
by publicENEMY
the easiest way to learn videolan command line is by trying the job in videolan and look at its generated command.

for example

server
1. open videolan. this will be the server.
2. Media -> Streaming. Choose the file you want to stream. Stream. In stream output, select RTP. put the server address. eg 127.0.0.1 is fine. Select MPEG-TS as the encapsulation(or any encapsulation you want)
3. note the generated stream output string. this will be the command line option. in my case its

Code: Select all

:sout=#duplicate{dst=rtp{dst=127.0.0.1,mux=ts,port=1234}}
4. Stream.

client
1. open videolan. this will be the client.
2. Media->Open Network. Select rtp as the protocol. put the server address(and port).
3. Show more options. note the command in Customize text box.

Code: Select all

rtp://@127.0.0.1:1234
this is the MRL for the streaming media. if you try to change the Caching parameters, the command line options will be generated next to the MRL.
4. Play

test the features using SimplePlayer(not SamplePlayer)

server.
1. open SimplePlayer. this will be the server.
2. in the open textbox put [MRL] [option1] [option2]...
3. in this case put

Code: Select all

c:\media.avi :sout=#duplicate{dst=rtp{dst=127.0.0.1,mux=ts,port=1234}}
4. Play.

Client
1. open SimplePlayer. this will be the client.
2. in the open textbox put

Code: Select all

rtp://@127.0.0.1:1234
3. Play

Remember, try what you want to do using videolan. capture the command line and then test it in SimplePlayer.

Thanks.

Re: C# example

Posted: 04 Nov 2008 11:08
by szhdyn
Hi.

Thank you for explanation.
Console commands are very useful!

Can I receive video stream and serve this stream to another IP:PORT at the same time using SimplePlayer?
Can I save video to hard disk?

Thanks.
Serhiy.

Re: C# example

Posted: 04 Nov 2008 15:21
by publicENEMY
Hi.

Thank you for explanation.
Console commands are very useful!

Can I receive video stream and serve this stream to another IP:PORT at the same time using SimplePlayer?
Can I save video to hard disk?

Thanks.
Serhiy.
read
Remember, try what you want to do using videolan. capture the command line and then test it in SimplePlayer.
You can receive stream and stream to others at the same time.
You can save video to hard disk.

Re: C# example

Posted: 04 Nov 2008 16:21
by vlcjean
Hello,

I'm trying to integrate VLC in a small C# application using the activeX plugin.

I'm able to play a local file with the following code:
int res = this.axVLCPlugin2.playlist.add(myVideoFile, "local file", null);
this.axVLCPlugin2.playlist.play();

But I when I replace the local video path by a link (HTTP or RTSP), the play does not start (no error is displayed). The code is the following:
int res = this.axVLCPlugin2.playlist.add("http://localhost/myVideoFile", "remote file", null);
this.axVLCPlugin2.playlist.play();

If I try to open the same file in VLC (stand alone player), the file plays perfectly.

Any ideas ?
Thx for your help

Re: C# example

Posted: 04 Nov 2008 20:05
by publicENEMY
is this

Code: Select all

http://localhost/myVideoFile
the exact command that you used in videolan and it works?

Re: C# example

Posted: 05 Nov 2008 08:48
by vlcjean
Yes, it is.

Re: C# example

Posted: 05 Nov 2008 09:31
by publicENEMY
how do you set up the server? are you using vlc? what is the server parameter? are you missing the port number? how do you set up the "myVideoFile"?
If I try to open the same file in VLC (stand alone player), the file plays perfectly.
are you opening file in videolan or are you opening http stream?

i tried http://localhost:8080 and it works like a charm.

Re: C# example

Posted: 05 Nov 2008 09:43
by vlcjean
My server is a basic Apache server. No special paramters are necessary.
As I said, when I open a remote file with the VLC player, I specify the link (http://localhost/myVideoFile.mp4) and the file is played. No configuration or explicit port is required. But when I try to open the same link from my C# app with VLC activeX plugin, the play never starts.

It seems to be a bug with the latest version of VLC (0.9.4), because I tried with an older version (0.8.6h) and it works perfectly...

Cheers

Re: C# example

Posted: 06 Nov 2008 10:32
by szhdyn
Hi.

I open videolan and stream video to 127.0.0.1:1234, than open SimplePlayer and put this string

:sout=#duplicate{dst=rtp{dst=127.0.0.1,mux=ts,port=1235}} than press Play

but it doesn't retrieve stream from 127.0.0.1:1234 and serve it to 127.0.0.1:1235

I think I do something wrong.

Thanks,
Serhiy.

Re: C# example

Posted: 06 Nov 2008 16:11
by publicENEMY
My server is a basic Apache server. No special paramters are necessary.
As I said, when I open a remote file with the VLC player, I specify the link (http://localhost/myVideoFile.mp4) and the file is played. No configuration or explicit port is required. But when I try to open the same link from my C# app with VLC activeX plugin, the play never starts.

It seems to be a bug with the latest version of VLC (0.9.4), because I tried with an older version (0.8.6h) and it works perfectly...

Cheers
i thought you are using vlc as streaming server(hence the weird parameters). AFAIK, that is not the proper way(although sometimes it works), but im not suprised if it doesnt. you can try rtp/rtsp for streaming.

by the way, is the bug in 0.9.4 activex or 0.8.6h activex or plain 0.9.4 or plain 0.8.6i? it works on 0.8.6i or o.8.6i activex?
Hi.

I open videolan and stream video to 127.0.0.1:1234, than open SimplePlayer and put this string

:sout=#duplicate{dst=rtp{dst=127.0.0.1,mux=ts,port=1235}} than press Play

but it doesn't retrieve stream from 127.0.0.1:1234 and serve it to 127.0.0.1:1235

I think I do something wrong.

Thanks,
Serhiy.
please provide complete parameters for each simpleplayer session. have you try it with videolanf? maybe you forget to put MRL.

Thanks.

Re: C# example

Posted: 06 Nov 2008 16:41
by szhdyn
Server 1 (VLC Player):
:sout=#duplicate{dst=rtp{dst=127.0.0.1,mux=ts,port=1234}}

Server 2(Simple Player):
:sout=#duplicate{dst=rtp{dst=127.0.0.1,mux=ts,port=1235}}
(This server must take video stream from Server 1 and serve it to another port for example to 1235.)

Client (Simple Player):
rtp://@127.0.0.1:1235

Server 2 takes video from Server 1 and serve it to another port. Client try to play video from Server 2. But it doesn't works.

Thanks,
Serhiy.

Re: C# example

Posted: 07 Nov 2008 05:34
by publicENEMY
Read
maybe you forget to put MRL.
the command should be

Server 1

Code: Select all

c:\file.avi :sout=#duplicate{dst=rtp{dst=127.0.0.1,mux=ts,port=1234}}
Server 2

Code: Select all

rtp://@127.0.0.1:1234 :sout=#duplicate{dst=rtp{dst=127.0.0.1,mux=ts,port=1235}}
Server 3

Code: Select all

rtp://@127.0.0.1:1235
nevertheless, i tested that in 0.9.4 and it failed. but when tested in 0.8.6i, it works. looks like you have found a bug in 0.9.4

Re: C# example

Posted: 07 Nov 2008 19:29
by szhdyn
Thank you very much for your help.

I will try this with another version of player.

Maybe You know the way how to retrieve datagrams using SimplePlayer?
Can I change datagram somehow before show video on the form?

Thanks,
Serhiy.

Re: C# example

Posted: 11 Nov 2008 23:24
by szhdyn
Hi!

Does anybody know how to fix this bug?

Thanks,
Serhiy.