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:
VLC media player can be used with command prompt (.NET implementation):
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):
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.
Thanks!
Once I get the IP camera, I'll give it a shot and let you know how it goes.
Brendan
Hello,
many thanks for this useful threat! I'm using your example VI with the snapshot function.
What I'm still looking for is the function to play a film in a different speed (e.g. 4 times faster). In the original VLC media player, this function can be found under "Playback" => "speed". I searched in the documentation of the VLC dll functions, where I could find it...without success yet. Anybody could give me a hint?
Greetings!
Olli
I tried already the "set rate" function (see the attached picture of the diagram). But even if it returns a "0" for functionality and another "get rate" function after returns the rate setting, the film is always played with normal speed, I tried also different positions of the "set rate" function in the diagram...no changes in the result ;-(
Hi,
I think you are on the correct path with "_set_rate" but if you check LibVLC documentation it states:"-1 if an error was detected, 0 otherwise (but even then, it might not actually work depending on the underlying media protocol".
-Artur
P.S. Attached example works for mp4 files...
Hello,
thanks for your fast reply and the useful hint!
I found the error right now. It was the wrong numeric format (8-bit double precision) I used for the variable "rate" in the function "libvlc_media_player_set_rate". I simply tested the other only option: 4-bit single precision....and it works ;-)))
Have a nice day!
Olli
Sometimes 4 bits is all you need to get it going!!!
Good Job,
-Artur
P.S. I would move some objects in your printscreen outside the for loop...
Really helpful.
How to close the VLC after an MP3 played?
Thanks
-RJ
Hi Artur,
could you help me with AtmoLight filter?
Thans a lot.
Best Regards.
Michele
Hi Arthur
could help me with Atmo Filter?
Thanks a lot.
Michele.
Hi Michele,
While there is no direct filter interface in "libvlc.dll" and not all the options are available via "libvlc_media_add_option" you should be able you use VLC filters with "transcoding"
- I do not have atmoFilter device at hand, but example below should help with setting atmofilter parameters:
:sout=#transcode{vcodec=h264,vfilter=gradient}:duplicate{dst=display}
:sout=#transcode{vcodec=h264,vfilter=invert}:duplicate{dst=display}
Tested -> works!
Try this:
:sout=#transcode{vcodec=h264,vfilter=atmo{device=1,serialdev=COM2}}:duplicate{dst=display}
-Artur
11/18/2015
Tested with VLC v.2.0.5 - works no problems
Failed with VLC v.2.2.1 - hwnd dll call fails to display video content in specified window
Hello Arthur,
great thanks for your work! Now I need your help. Im trying to implement an window in my frontpannel where the video of a my camea is shown. The videosignal of the camera (composide video) is grabbed by an USB Videograbber (BR116). I only want so see this video in the frontpannel without doing any manipulation (like stop or snapshot funktion).
By testing i found out the correct settings for vlc to get the video grabber signal. I wrote a .bat file so I can start vlc with the right settings.
dshow:// :dshow-vdev="OEM Device" :dshow-adev=none :dshow-aspect-ratio=4\:3 .... an so on
were I have to put this information in your labview VIs ? I tried many things but without succses I only get a black window.. with "screen://" putting in "Media Source" its working
Thanks a lot
lg Julian
Hi,
Used to work...
You should be able to specify dshow device ether way as "Media Source" or with "Options" but looks like now it doesn't work.
I will see if I can find a solution.
At the moment looks like options are ignored and vlc selects default dshow device.
-Artur
Hello Everyone,
Thank you for all of the information and examples. Could someone help me with adding a rotate or flip function to a USB camera feed that I am using for an inspection station? I would prefer to do it while the video is live (or even stop, flip, and restart) but having it start rotated when LabVIEW is ran will work also. I have tried adding the "video-filter=rotate rotate-angle=180" as well as "video-filter=transform transform-type=vflip" commands to the "libvlc_media_add_option" section but no change. I have also tried working with the property and invoke nodes for the picturebox but still no change. I have also tried adding another call library function node and tried to find a function in the libvlc.dll but again, no luck. I am able to do this using SysExec but can't figure out how to pass commands to the already open window. Any help would be much appreciated. Using LV2012 and VLC 2.2.4; Picture of code posted below.
On a side note...I have been successful in adding a "STOP" and "PLAY" button, I tried using a pause button but the video lags for the amount of time paused when un-paused. If anyone is interested in this, please let me know.
Hello,
I am trying to use the examples from this post to capture images from an AverMedia Capture Card. I have a PC configured with 4 AverMedia devices (all same model) and I want to select which capture card I want to stream from.
When I try to use the "Play Stream&Snapshot.vi" with the "Media Source" as "dshow:// :dshow-vdev="Avermedia X" to stream I can't choose an specific device, it always goes with the same, and probably, "default" device.
All I need to do is stream the captured images in an ActiveX object.
Does anyone has the same issue?
Thanks in advance.
Regards.
Dears,
I am using VLC - Example (set pos).vi as a base of my program. However, in .exe mode the video is showed in a new window every time that I run it. In other words the program runs ok at once, however when I open it again a new vlc windows open.
have you seen it?
tks
Arthur,
This is good stuff. I tried your vi to get statistics but the VI didn't run. Or, it did run and nothing happened?
Please help.
J
Hello every one,
I am trying to stream live video from my IP Camera in LabVIEW. Streaming is already working with VLC. Now I am trying to do the same using libvlc.dll in LabVIEW but I donot know how?
I downloaded the examples above and I can play normal video in LabVIEW.
To capture video from my IP camera, I need to set, in VLC, these parameters: --demux=h264 --network-caching=500 --h264-fps=29.98 rtp://@:5022. The question is which libvlc.dll function should I use toset these parameters in LabVIEW?
Thanks a lot in advanced
hi, can you help me? is it possible when the output video stream becomes a regular image? I have to process those live streaming video but it has to be an image such as u8, u16, rgbu32, i16, rgbu64, sgl. help me, please
Hey Artur,
I took the liberty to modify one of you VIs (VLC - Convert Video to mp4.vi) and created one to convert to AVI, so we could automate other formats convertion to AVI so the videos could be open by NI Vision Development Module (VDM) functions in LabVIEW. I basically changed some parameters of the transcode command.
As a note, it is important to use a codec supported by NI Vision Development Module, that could be found by running the function IMAQ AVI2 Get Codec Names.vi. I also did not included the audio information in the AVI.
In my example, I used the Motion JPEG codec.
I also create an example project where you can convert and MP4 video to AVI and then opening using AVI functions from NI VDM.
I also add a code for running the AVI as a video in LabVIEW. Here is the snapshot.
I hope that helps any of you! 😀
I tried using the VLC - Play Stream&Snapshot.vi as well as VLC - Play Stream&Snapshot&speed.vi
both give me same error No: 12 "Call Library Function Node in VLC - Play Stream&Snapshot&speed.vi"
exactly after the library calling function:
I checked the path is correct. Any idea to solve this issue?
I'm using LabVIEW 2020 32bit, Windows 10 64-bit, and VLC media 64-bit.
should I redownload VLC media for 32-bit?
Hi Branch_Support-
https://forums.ni.com/t5/Example-Code/VLC-scripting-in-LabVIEW/tac-p/4050759/highlight/true#M14377
Your example is very nice.
Do you have any Idea if I would convert it directly to stream as IMAQ image instead of save it previously in a file?
@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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
Hi Hooovahh, 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?
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
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,
Hi,
do you know how to change the video resolution using the codes attached in this article ?
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 Branch_Support-
I didn't realize that I just wrote Hi to you and say nothing. I'm sorry for that post. I deleted.
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?
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
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
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.
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
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?
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.