Usage of libvlc.dll in C#

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
ravi_andhra
Blank Cone
Blank Cone
Posts: 12
Joined: 12 May 2008 09:42

Re: Usage of libvlc.dll in C#

Postby ravi_andhra » 31 May 2008 08:04

Hi,

I need to embed VLC into my C# application so as to display the live video that is being captured by my web camera.

Anyone can help?


Thanks!

Sarah

hi
have you found the solution to the above problem ?

Kin
New Cone
New Cone
Posts: 2
Joined: 11 Jul 2008 16:13

Re: Usage of libvlc.dll in C#

Postby Kin » 11 Jul 2008 20:29

Hi,

I am using the sample code on the first page too and I need to capture, display and send a video stream that is being caught by my web camera

to capture and diplay, I did something like this...It's woks fine

Code: Select all

LibVlc vlc = new LibVlc(); vlc.Initialize(); vlc.VideoOutput = pictureBox1; vlc.PlaylistClear(); vlc.AddTarget(""dshow://", ":dshow-vdev=\"<name of video device>\"""); //vlc.AddTarget(""dshow://", ":dshow-vdev=\"Dlink DSB-C320\"""); for instance vlc.Play();
but, to send a stream I try and this didn't work:

Code: Select all

vlc.AddTarget("dshow:// :dshow-vdev=\"\"Dlink DSB-C320\"\" :sout=#transcode{vcodec=mp4v,vb=1024,scale=1}:duplicate{dst=display,dst=std{access=udp,mux=ts,dst=192.168.0.107:5000}}");
What's wrong?
How can I handle the duplicate stream and sent it over the net?

Thanks in advance

shooter
New Cone
New Cone
Posts: 1
Joined: 08 Oct 2008 19:15

Re: Usage of libvlc.dll in C#

Postby shooter » 08 Oct 2008 19:18

can u pls mail me the c# wrapper i need it...
:)

Franko73
New Cone
New Cone
Posts: 1
Joined: 19 Nov 2008 17:01

Re: Usage of libvlc.dll in C#

Postby Franko73 » 19 Nov 2008 17:04

I am trying to get the video to play slower using vlc.SpeedSlower() but it dont seem to make any difference, the video plays at normal speed no matter how many vlc.SpeedSlower() I use, any help. If I put the vlc.SpeedSlower() in a seperate button code it works but I want the video to play at slowest speed from the start. Any help appreciated, thanks

I am also trying to capture a single image from the picturebox but there is no method to grab a snaphot, any ideas?

LibVlc vlc = new LibVlc();
vlc.Initialize();

vlc.VideoOutput = pictureBox1;
vlc.PlaylistClear();
vlc.AddTarget("C:\\test.avi");

vlc.Play();
vlc.SpeedSlower() ;

ChrisHolmesOnline
Blank Cone
Blank Cone
Posts: 19
Joined: 13 Dec 2008 00:55

Re: Usage of libvlc.dll in C#

Postby ChrisHolmesOnline » 31 Dec 2008 18:06

Code: Select all

Functions.LibVlc vlc = new Functions.LibVlc(); vlc.Initialize(); vlc.VideoOutput = pictureBox1; vlc.PlaylistClear(); vlc.AddTarget("S:\\test.avi"); vlc.Play();
Thats the code I used to make it work. I did change the namespace in my applicaiton to Fucntions.LibVLC though so that line would need changed. Also pictureBox1 needs to be changed to the name of your picturebox.

That code just when inside the button clicked code.

Hope that helps.
I'm doing this exactly, but it doesn't work. So I decided to check if the Initialize() method was returning True, and it was not:

Code: Select all

LibVlc.LibVlc v = new LibVlc.LibVlc(); v.VlcInstallDir = VlcHelper.VlcInstallationFolder; if(!v.Initialize()) { MessageBox.Show("Could Not Initialize"); return; } v.VideoOutput = panel1; v.PlaylistClear(); v.AddTarget("test.avi"); v.Play();[
The MessageBox displays because the LibVlc fails to initialize. So I dug down into that code and wrapped the Initialize() method in a try-catch block. It fails on the call to VLC_Create, around line 520:

Code: Select all

m_iVlcHandle = VLC_Create();
The Exception is a EntryPointNotFoundException: Unable to find an entry point named 'VLC_Create' in DLL 'libvlc'. Anyone have any idea why this is happening?

illogique
New Cone
New Cone
Posts: 1
Joined: 11 Jan 2009 03:57

Re: Usage of libvlc.dll in C#

Postby illogique » 11 Jan 2009 04:04

@ChrisHolmesOnline:

I presume that you are using the new version of VideoLAN - something from the 0.9 tree?

If so, the old methods created by Odysee will no longer work. The exports (functions/data within a DLL) which exist in the libvlc.dll have changed. For example, libvlc_new has replaced VLC_Create which was around in version 0.8.6.

There are two choices I see: updating the .Net wrappers to support the new code, or using an older version of VLC to get what you need done.

Hope this helps!

kryptonite
Blank Cone
Blank Cone
Posts: 52
Joined: 22 May 2009 12:01

Re: Usage of libvlc.dll in C#

Postby kryptonite » 22 May 2009 12:04

Is there some documentation listing the API mappings to those in the newere 0.9 x releases?

Thanks!

stiwan
New Cone
New Cone
Posts: 1
Joined: 28 Oct 2009 09:52

Re: Usage of libvlc.dll in C#

Postby stiwan » 28 Oct 2009 09:55

hey there folks.

great work.

i had to deal with the "could not find libvlc" issue. and it appears to me that you have to copy older files (like version 0.8.6i) from the program directory (c:\program files\videolan\vlc\)
are there any plans to make it work with the 1.0 series?

thanks for the great c# class :)
stiwan

hishwest
New Cone
New Cone
Posts: 1
Joined: 07 Mar 2010 11:42

Re: Usage of libvlc.dll in C#

Postby hishwest » 07 Mar 2010 11:47

hello , plz i try this sample but it doesn't work ;this error is shown "'LibVlc.Form1.Dispose(bool)': no suitable method found to override i'm; interested of your code

Umer_Zahid
New Cone
New Cone
Posts: 2
Joined: 16 Mar 2010 10:45

Re:

Postby Umer_Zahid » 16 Mar 2010 17:13

Hi Odysee, you have done a fantastic job. you have written that you have written wrapper in managed c++ (assembly)! can you email me that code.... i will be very grateful to you. my email is (umi729@gamil.com)
regards
Umer Zahid

qontranami
New Cone
New Cone
Posts: 4
Joined: 10 Sep 2010 01:33

Re:

Postby qontranami » 10 Sep 2010 09:22

Hi Odysee,

Please email me a copy of the wrap-around code at

qontranami [at] yahoo [dot] com

Thanks.

Jaco
New Cone
New Cone
Posts: 6
Joined: 28 Aug 2010 21:04

Re: Usage of libvlc.dll in C#

Postby Jaco » 13 Sep 2010 21:12

WHY WHY WHY!!!! ????

// init libvlc
Error errVlcLib = VLC_Init(m_iVlcHandle, strInitOptions.Length, strInitOptions);

A call to PInvoke function 'WindowsFormsApplication1!LibVlc.LibVlc::VLC_Init' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

Im gona start coding in C again if no one helps me with this frustrating wrapper !!! I am using VLC 0.8.6 in Windows 7 and coding in C# obviously !??

Why is it not workinggngngggn!!!!!!!!!!!!!!!!!

Titanic
Blank Cone
Blank Cone
Posts: 33
Joined: 14 Sep 2010 10:12

Re: Usage of libvlc.dll in C#

Postby Titanic » 14 Sep 2010 10:25

Had a similar problem. Solved it by changing the calling convention to Cdecl instead of Winapi/Stdcall for all InterOp functions

Example:
[DllImport("libvlc", CallingConvention=CallingConvention.Cdecl)]
internal static extern IntPtr libvlc_new(int argc, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)]string[] argv);

siolor
New Cone
New Cone
Posts: 2
Joined: 14 Oct 2010 07:45

Re: Usage of libvlc.dll in C#

Postby siolor » 14 Oct 2010 07:53

Hi guys,

I'm trying to play some RTSP stream by using the libvlc.dll.
I'm able to display the stream without any problem but when it comes to a stream that require a user/password i got stuck.
Is there any option to define ?!?

any idea ?

edit : I finally found the ealier "libvlcnet - .NET library based on libvlc". It's based on a earlier version of VLC and i can now run my RTSP stream without any problem.

Mudita
New Cone
New Cone
Posts: 1
Joined: 18 Mar 2011 18:53

Re: Usage of libvlc.dll in C#

Postby Mudita » 18 Mar 2011 18:58

hi Odysee.....

will u please mail me...the wrapper c++ project that u had made..
my id is: mudita7538 at gmail dot com

thanx in advance..

ARUNCB
Blank Cone
Blank Cone
Posts: 11
Joined: 23 Jul 2014 13:35

Re: Usage of libvlc.dll in C#

Postby ARUNCB » 25 Jul 2014 14:06

Did someone got an answer for this? I am stuck by this :cry:
How can I get the Stats information?

For example, using the following I can get the Meta Information from your .NET control:

const String Meta_information = "Meta-information";
public string GetMetaInfo(string strMetaParam) {
using (VlcObject vobj = new VlcObject
(this.vlcHandle, ObjectType.VLC_OBJECT_INPUT)) {
if (vobj.SubObject != IntPtr.Zero) {
IntPtr resultString = IntPtr.Zero;
input_Control(vobj.SubObject,
input_query_e.INPUT_GET_INFO,
Meta_information, strMetaParam, ref
resultString);
string res = Marshal.PtrToStringAnsi
(resultString);
return BaseTools.UTF8ToIso8859(res);
}
}
return "";
}

But a similar approach does not work for the Statistical Data from a stream?
For example, I tried to get the Statistical data using this function but it doesn't work:

const String Stats_information = "Stats-information";
public string GetStatsInfo(string strStatsParam) {
using (VlcObject vobj = new VlcObject(this.vlcHandle,
ObjectType.VLC_OBJECT_STATS))
{
if (vobj.SubObject != IntPtr.Zero) {
IntPtr resultString = IntPtr.Zero;
input_Control(vobj.SubObject,
input_query_e.INPUT_GET_INFO,
Stats_information, "Decoded blocks", ref
resultString);
string res = Marshal.PtrToStringAnsi
(resultString);
return BaseTools.UTF8ToIso8859(res);
}
}
return "";
}

Could you tell me how to get any of Statistical Information above using your .NET interface?
/* Input */ "Input"
INPUT_ADD( "Read at media", read_bytes_text, "0" );
INPUT_ADD( "Input bitrate",
input_bitrate_text, " 0" );
INPUT_ADD( "Demuxed", demux_bytes_text ,"0");
INPUT_ADD( "Stream bitrate", demux_bitrate_text, "0" );
/* Sout */ "Streaming"
SOUT_ADD( "Sent packets",
sout_sent_packets_text, " 0" );
SOUT_ADD( "Sent bytes", sout_sent_bytes_text, "0" );
SOUT_ADD( "Send rate", sout_send_bitrate_text, "0" );
/* Vout */ "Video"
VIDEO_ADD( "Decoded blocks", video_decoded_text, "0" );
VIDEO_ADD( "Displayed frames", displayed_text, " 0" );
VIDEO_ADD( "Lost frames", lost_frames_text, "0" );
/* Aout */ "Audio"
AUDIO_ADD( "Decoded blocks", audio_decoded_text, " 0" );
AUDIO_ADD( "Played buffers", played_abuffers_text, "0" );
AUDIO_ADD( "Lost buffers", lost_abuffers_text, "0" );
thanks!!

ARUNCB
Blank Cone
Blank Cone
Posts: 11
Joined: 23 Jul 2014 13:35

Re: Usage of libvlc.dll in C#

Postby ARUNCB » 30 Jul 2014 06:16

Some one please help. I am stuck in this case, I would like to know how VLC player get the data of stream video, but LibVLC.net not. I tried the "libvlc_media_player_get_fps " method,

It give me 0.0 for stream video

ARUNCB
Blank Cone
Blank Cone
Posts: 11
Joined: 23 Jul 2014 13:35

Re: Usage of libvlc.dll in C#

Postby ARUNCB » 26 Aug 2014 08:22



Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 5 guests