LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating screen recording app with labview

I tried all the examples made in labview,

example-1 

example-2 

example-3 

example-4 

 

 

 

 

but there is a problem with the save speed.
When I measured the while loop refresh rate it was 900 ms. I came to the conclusion that the user32.dll file was causing the slow operation.
No matter what I do, I cannot record the recording at normal speed. The video is recorded with very fast steps. Because the number of photos it takes is very low. Does anyone know the solution to this?constructionworker_0-1667646792378.png

 

Why is the loop timing running so slow? constructionworker_1-1667646892343.png

 

Any opinion given is worthy of respect

 

0 Kudos
Message 1 of 24
(3,625 Views)

To get faster capture you have to use Windows GDI functions instead of Print Screen and Clipboard.

 

Most easiest way is to build small wrapper library, quick and dirty something like that:

 

Screenshot 2022-11-06 101516.png

LabVIEW code:

Screenshot 2022-11-06 101648.png

On my PC capturing running approx at 30 FPS:

Screenshot 2022-11-06 101916.png

Full project in attachment (LabVIEW 2022 + VDM + CVI 2020).

Message 2 of 24
(3,556 Views)

The while loop refresh rate also varies depending on the type of codec selected when recording screen video. is the "Motion JPEG (NI Vision)" codec type that I use now. The FPS specified in IMAQ AVI2 Create VI only determines the playback speed of the video. For example, if I choose 30 FPS, the video is recorded at 30 frames per second according to the time, but in reality 30 photos are not taken in one second, only 6 photos are taken. I can take a maximum of 15 photos. The while loop refresh rate has an effect on the number of photos that can be taken here. And the video in general moves very fast.

Is there any way to overcome this problem with Labview?

Does anyone know how to fix this issue?

 

I am testing it with the following example.

0 Kudos
Message 3 of 24
(3,548 Views)

@Andrey_Dmitriev wrote:

To get faster capture you have to use Windows GDI functions instead of Print Screen and Clipboard.

 

Most easiest way is to build small wrapper library, quick and dirty something like that:

 

 

LabVIEW code:

Screenshot 2022-11-06 101648.png

On my PC capturing running approx at 30 FPS:

 

Full project in attachment (LabVIEW 2022 + VDM + CVI 2020).


I'm using labview 2018 32-bit, I can't open the file.

0 Kudos
Message 4 of 24
(3,544 Views)

@constructionworker wrote:

using labview 2018 32-bit, I can't open the file.

Downgraded to LV2018 32-bit (and DLL recompiled as well).

Unfortunately I have the only 2022 Q3x64 installed, but hopefully you will be able to open it now.

I also have added AVI record. The codecs provided by NI are not very optimal for screen recording, with Motion JPEG (NI Vision) on my 2560x1440 desktop and i7-3740QM I have 12-13 FPS, which is not so bad.

0 Kudos
Message 5 of 24
(3,528 Views)

Thanks for your help. I think I understand the problem better now. The reason for the FPS drop is 2 screen usage. The example you shared is 30 FPS with one screen and 15 FPS recording with two screens. codec:Motion JPEG (NI Vision)

This is how it worked with the example I shared earlier.

constructionworker_0-1667739161205.png

 

 

But this FPS problem does not occur when I record two screens with a normal recorder application.(I'm recording with mp4 in lower quality. I think there is something about this.)

 

The CPU I am using is i7-7500U CPU 2.70 Ghz 

What do you think is the solution to this problem?

0 Kudos
Message 6 of 24
(3,511 Views)

Well, if you perform recording of two monitors with large desktop, then performance can drop.

The only enhancement point what you can do is to split capturing and encoding into two loops using producer/consumer design pattern, something like this:

Screenshot 2022-11-06 184411.png

Full code in the attachment (LV2018)

 

For further enhancement there are two obvious points - capturing and encoding. GDI+ is not the only possible way to capture, may be something DirectX-based will be faster (but I'm not very familiar with this). Encoder can be replaced with OpenCV (you will get more codecs available). Also using ffmpeg could be possible. If your actual recording tool is open source you can take a look inside how it works and which technology used behind, but integration into LabVIEW (if you prefer to have recorder frames in IMAQ images) could be painful.

 

0 Kudos
Message 7 of 24
(3,469 Views)

 


@Andrey_Dmitriev wrote:

Well, if you perform recording of two monitors with large desktop, then performance can drop.

The only enhancement point what you can do is to split capturing and encoding into two loops using producer/consumer design pattern, something like this:

 

Full code in the attachment (LV2018)

 

For further enhancement there are two obvious points - capturing and encoding. GDI+ is not the only possible way to capture, may be something DirectX-based will be faster (but I'm not very familiar with this). Encoder can be replaced with OpenCV (you will get more codecs available). Also using ffmpeg could be possible. If your actual recording tool is open source you can take a look inside how it works and which technology used behind, but integration into LabVIEW (if you prefer to have recorder frames in IMAQ images) could be painful.

 


First of all, thank you for your hard work. The second version seems to work better.The producer-consumer model has improved a bit.
I actually have 3 1920x1080 monitors, not 2.

Last time I tried what you shared, 2 monitors can reach a speed of 28-29-30 FPS with 3 monitors 15-16 FPS.

 

Yes, I think it may be possible to record faster with different codecs.I capture videos directly from the devices I use with NI-Vision.

 

Frankly
I need to do some research on how to capture with directx. But I don't know the exact possibility of doing this.
I've never worked with -labview opencv. I wonder how it could work. However, I think this requires extensive knowledge.
The FPS capture I want with NI-Vision seems a bit difficult. Because AVI files are large in size. It takes some time to process.

-Currently I don't want preview while recording but I need to know that it only records on 3 screens.

 

0 Kudos
Message 8 of 24
(3,455 Views)

I found  an example with Directx on the your suggest  but it only takes one picture of a screen.

I'm not sure but it seems like really faster photo capture with Directx.

 

0 Kudos
Message 9 of 24
(3,438 Views)

@constructionworker wrote:

I found  an example with Directx on the your suggest  but it only takes one picture of a screen.

I'm not sure but it seems like really faster photo capture with Directx.

 


This example is based on .net Wrapper, which is slightly obsolete and wasn't updated for last 12 years. My attempt to target it to latest .net framework and recompile in VS 2022 was just failed. In additional, some possible overhead could be expexted in managed/unmanaged code.

 

Most light weight and tiny recorder I've ever seen is here: https://github.com/WindowsNT/ScreenCapture.

Can be relative easy integrated with LabVIEW, but small warapper is still needed.

0 Kudos
Message 10 of 24
(3,414 Views)