Example Code

VLC scripting in LabVIEW

Code and Documents

Attachment

VLC media control's ActiveX (while great under Internet Explorer) crashes LabVIEW upon insertion (LabVIEW Vers. 09/10/11/12 - R&D - any ideas why?), and functionality is limited due to security attributes applied to ActiveX itself. With examples below much more advanced features can be accessed and utilized while building interface in LabVIEW enviroment.

Requires VLC media player installed. No Error check provided if VLC not installed

Tested under Windows XP/VISTA/7 32bit and 64bit

Get Program Location (path).vi was created to simplify integration into 32-64 bit systems, other methods can be used or constants can be wired instead.

Supports:

  • Video/Audio file playback
  • IP cameras stream playback
  • DirectShow playback
  • Video/Audio streaming
  • Video/Audio encoding/decoding
  • see more details on VideoLAN forums and documentations

VLC media player can be used with command prompt (.NET implementation):

VLC dotnet scripting.png

Process refnum can be used to control VLC application, i.e. proper closing (close main or kill process methods)

Note: --drawable-hwnd command from command prompt doesn't work properly, VLC media player end up creating it's own Direct3D output window. Tryied to create non-LabVIEW generated windows over API/DOTNET/VB scripting with no success. (with or without WS_CHILD and WS_CLIPSIBLINGS flags).

Or over DLL (example where VLC embedded into LabVIEW window):

VLC Embedded.png

Check for tipstrips...

Update: 8/19/2013

VLC - Fullscreen.vi - example how to pass options to VLC media player and fullscreen option.

Update: 7/30/2014

VLC - Convert Video to mp4.vi - example how to convert video file for Iphone/IPad playback (Web hosting)

Update: 8/19/2014

VLC - Play Stream&Snapshot.vi

Update: 9/03/2014

VLC - Save Stream.vi - save video stamp with text and logo

Note: snapshot function doesn't work...https://forum.videolan.org/viewtopic.php?f=14&t=104610

One of the solutions can be to use 'scene" filter instead...

Update: 08/31/2015

VLC - Play Stream&Snapshot&speed.vi

-Artur

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

@ThamS - I was seeing the same error 12, and yes it looks like this is related to trying to call the 64-bit VLC binary, from the 32-bit version of LabVIEW.  I downloaded the latest version of VLC Win32 from here, then made sure that the DLL path to libvlc.dll, was to the one in the Program Files (x86) folder.

ThamS
Member
Member
on

Hi  , Yes Thank you.

However I still cant figure out how to grab the picture from this VLC scripting vi into LabVIEW image (JPG, PNG, BMP, etc) or either IMAQ Image.

If some one could figure it out?

Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

I didn't have any problem at all.  Once I got a live feed working with the right version of VLC, I then used the libvlc_media_new_location as "dshow://" and called the libvlc_media_add_option with "dshow-vdev=USB Video Device" replacing it with the name of my USB camera.  Then I had a working live feed on a .Net picture box, and then called the libvlc_video_take_snapshot and saved it on disk.  Both getting a live feed, and taking a snapshot is shown in the examples above.  No IMAQ needed which is great for me because I didn't want to have to pay for a deployment license of a vision toolkit, when really all I wanted was to view and save pictures.  Also I tried enumerating all USB cameras on my system, but couldn't get it to work without needing admin rights to run a power shell script, or devcon.  WMIC partially worked but wouldn't work right with two of the same camera.

Marooo199
Member
Member
on

Hi GriffinRU,

 

 

I want to run RTSP video using RTSP URL, how I can use your code to do that?

I want to record The video and store the recorded video in my PC, please help me.

 

 

 

Regards, 

Marooo199
Member
Member
on

Hi, 

 

do you know how to change the video resolution using the codes attached in this article ?

 

 

 

ThamS
Member
Member
on

Hi Marooo199,

I Just would let you see https://forums.ni.com/t5/Example-Code/VLC-scripting-in-LabVIEW/tac-p/4050759/highlight/true#M14377 by   above. in case that is what you need but you missed it.

I didn't realize that I just wrote Hi to you and say nothing. I'm sorry for that post. I deleted.

ThamS
Member
Member
on

Any body know how to get time stamp from the RTSP media?

 

I'm using the VLC - Play Stream&Snapshot.vi above.

In my case, when I use it for a long continuous streaming, the vlc media seems like streaming but the image doesn't updated (no change).

I can't figure out how to detect such issue, so that I could ask the program to re-initiate the connection.

I checked the is-playing function, it return true.

I checked the safe image to file (snap) function, it return true. while the image is replaced with the same as the previous image.

I don't know if we could check the media time stamp. is there any?

Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

This might be a pretty hacky solution, but can you compare the previous snap to the newest one?  If the image is bit for bit the same, then you can assume the camera locked up.  Even in a dark room I'd expect some variation in light levels on the sensor just from noise.  I've been working with some crappy cameras lately that lock up and I was thinking of ways to improve it by reinitializing too, but haven't tired anything yet.

KiranTeja
Member
Member
on

i am trying to get codec info by using the VLC codec information example, every time i run it LabVIEW crashes and given me the error memory access violation I did not know what i am doing wrong 

KiranTeja
Member
Member
on

KiranTeja_0-1640854675503.png

 

ThamS
Member
Member
on

Hi KiranTeja first of All, you need to make sure about the X64(64-bit) or X86(32-bit) of your LabVIEW as well as your VLC.

I always (As recommended by NI) use 32-bit version of LabVIEW.

In my experience, calling the library of VLC x64-bit within LabVIEW x86(32bit) will return error.

So, I've to use VLC x86(32-bit) for this case.

themadgreek
Member
Member
on

Hi Artur,

 

Thanks for sharing your examples here on the forum. I am trying to have an ip camera stream from VLC on LabVIEW. Currently i am streaming the live camera footage in VLC via RTSP stream. I tried using your example (VLC - Play Stream&Snapshot.vi ‏) and it didn't work for me, so I worked some changes on your example vi to do the task, but it doesn't seem to work for me either. I am attaching the your example Vi that i made changes to here.

 

I am using 64 bit LabVIEW (Ver 21.0)) and VLC (3.0.17.4). The main change i did to your example is path for the DLL file, mine is  (C:\Program Files\VideoLAN\VLC\vlc.exe). 

 

Also are we suppose to use the same RTSP address used in VLC for live stream in the example VI too?

 

Hoping to get some suggestions, recommendations and insight on this matter.

 

Thanks,

themadgreek

 

VLC on LABview.PNG

jjbloomfield
Member
Member
on

I am trying to use the VLC -  LabVIEW embedded.vi example.  Installed VLC version 3.0.17.4 on Windows 10 64bit.  I'm running LabVIEW 2021 64 bit.  The example calls a series of dll functions from libvlc.dll, which is my case is being correctly located in C:\Program Files\VideoLAN\VLC.  The first function call, "libvlc_new" runs successfully but the subsequent function calls return error 1097 that an exception occurred.  Any ideas what could be the problem?  I need to run LabVIEW 64 bit for memory capacity for my application.  Has anyone successfully embedded VLC in LabVIEW 64 bit?

jjbloomfield
Member
Member
on

So this post pointed me in a positive direction.  I changed the function data types to I64s where they were i32.  Now the dll function calls don't return the exception error 1097.  However, I'm not seeing anything happening with VLC player.

 

John B.

Contributors