Example Code

Record Video of LabVIEW front panel and block diagram to AVI

Code and Documents

Attachment

Description:

This VI programmatically will press the print screen key, copy the clipboard image into an IMAQ image, then save it to an AVI. This will allow you to create an AVI recording of the LabVIEW environment. Please not there is a limitation that if you click on other applications this will not work; you must stay within the LabVIEW environment.

Steps to Complete:

1. Open VI

2. Select File Path with a .avi extension

3. Run VI

4. Stop VI

5. Navigate to the AVI you saved and open it.

screenshot block diagram.PNG

screenshot front panel2.PNG

Applications Engineer
National Instruments

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

Comments
GriffinRU
Member
Member
on

Well, it suck's to be limited with keyboard events, right?

My example, let's you fly through windows, and even let you capture events which are supressed by printscreen or alt-printscreen btn.

-Artur

Daniel_Weng
Member
Member
on

Hi Artur

  Thank u for your very useful example and may i ask a question about the AVI file size.

filter name.JPG

i know the XVID filter is good for the compression but i can not got it in my computer although this filter have been installed on my computer. May i ask do you have experience that directly recall XVID sdk to use this filter and do not depend on labview. Or do you have other suggestion that can help me to got relatively small avi size and the video quality is just to watching.

Thanks

Daniel

GriffinRU
Member
Member
on

Hello Daniel,

Check this thread

I think with "ffdshow 1681" you will have great success.

-Artur

Daniel_Weng
Member
Member
on

Hello Artur

  Thank you very much for your reply and i can got the ffdshow in the filter list.

  But the captured avi file has some problem when i play the avi file. i am not sure whether my setup have any problem for i install the ffdshow in all default setup.

Thanks

Danieluntitled.JPG

GriffinRU
Member
Member
on

Hello Daniel,

Can you specify which code (VI) you use to capture video.

Looks like bit depth mismatch...

-Artur

Daniel_Weng
Member
Member
on

Hello Artur

  Please see the attached code PIC. The code(printscreen to IAMQ) is you once posted on the website. I am not sure whether my using method was correct or not. Why will cause this problem.

Thanks

Daniel

code-1.JPGcode-2.JPG

GriffinRU
Member
Member
on

Daniel,

During capture image displays properly? If, yes then you have some problems with encoding. If, no then there is a problem with .net desktop screen capture.

I've checked .net desktop capture subvi under WinXP 32bit and Win7 32bit and 64bit, works properly.

-Artur

Daniel_Weng
Member
Member
on

Hi Artur

  The capture image was correct but when saved as AVI file,the output was incorrect. But when i use your another file that directly save capture image as AVI file and also use the same code. it was correct. So i think maybe the problem is on frame rate and the delay time.

Thanks

Daniel

GriffinRU
Member
Member
on

Hello Daniel,

If during capture image display was correct, then problem is with Vision encoding. Timing shouldn't create such problem, it would only disturb data in time, there are better ways to capture desktops while preserving timing information, you can explore that later.

Now, looks like you have problem encoding data to AVI-file. From attached picture, looks like you are using 2nd generation AVI tools. I do not have 2nd gen installed on my machine (for various reasons), so -> Have you tried to capture uncompressed video or using different filter with the same code?

-Artur

Daniel_Weng
Member
Member
on

Hi Artur

  you are correct the problem is on the encoding. when i change the encode to the "Microsoft Video 1" the problem was solved.

Thanks

Daniel

GriffinRU
Member
Member
on

Hello Daniel,

While it is fun to capture desktop with NI Vision (and learn how to overcome some bugs and/or shortcomings), but have you considered using VLC or Gstreamer for the same task? You can specify window of interest and scale with various compression formats plus you can add audio...

-Artur

P.S. Or depends on your application you can stream video over the network.

Daniel_Weng
Member
Member
on

code.jpg

Hi Artur

  Thank you give me a new method for this task. But when i install the VLC and want to insert ActiveX in labview, The labview will be crashed immediately. My labview was 2013. I am not sure whether my method have any problem or VLC can not be used in labview.

  Second what you mean stream video over the network? you mean share the desktop to another computer?

  Thank you very much that you give me great help.

Thanks

Daniel

GriffinRU
Member
Member
on

Hello Daniel,

VLC's ActiveX crash in LabVIEW is known bug for sometime... Check this thread  how to use VLC in LabVIEW.

And, yes you can stream your desktop or part of it with VLC over the network, i.e. from one computer to another.

-Artur

P.S. Same true for Gstreamer, I just haven't uploaded examples, yet...

and I think we should leave this thread alone and continue on VLC thread or over private messaging.

Daniel_Weng
Member
Member
on

Hi Artur

  Thank you very much and i will study the VLC at first and if have some question that i will post on that thread and hope can get your help.

Thanks

Daniel

sattish@102
Member
Member
on

 i need VI how to grab video and store in buffers please help me

Contributors