AdvancedHMI Software

General Category => Feature Request => Topic started by: joko markono on December 27, 2019, 03:20:21 AM

Title: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on December 27, 2019, 03:20:21 AM
Hope to have this tool: https://www.advancedhmi.com/forum/index.php?topic=976.msg5123#msg5123 (https://www.advancedhmi.com/forum/index.php?topic=976.msg5123#msg5123)
can be upgraded with save function (e.g. avi, mpeg, etc)

Thanks.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on December 28, 2019, 03:02:24 AM
You could try using the attached modified LiveVideo control, with 3 new properties: RecordVideoToFile, RecordVideoFileName and RecordVideoCompressor.

It only does AVI files which will have different size depending on what video compressor you select.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on December 29, 2019, 09:39:38 PM
Thanks Godra. may i know how to start recording using button control?

example: RecordVideoToFile = True

Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on December 30, 2019, 01:42:59 AM
Keep it's RecordVideoToFile property as False, add a button to your form and try to use this code:

Code: [Select]
    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If Me.LiveVideo1.RecordVideoToFile Then
            Me.Button4.BackColor = Color.Red
            Me.Button4.Text = "Stop Recording"
        Else
            Me.Button4.UseVisualStyleBackColor = True
            Me.Button4.Text = "Start Recording"
        End If
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Me.LiveVideo1.RecordVideoToFile = Not Me.LiveVideo1.RecordVideoToFile

        If Me.LiveVideo1.RecordVideoToFile Then
            Me.Button4.BackColor = Color.Red
            Me.Button4.Text = "Stop Recording"
        Else
            Me.Button4.UseVisualStyleBackColor = True
            Me.Button4.Text = "Start Recording"
        End If
    End Sub

If the button turns Red after you start the app that should indicate that the property is already set as True.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on December 30, 2019, 01:57:50 AM
Thanks Godra, i have tested it.

Here is the file size that i roughly calculated:
for 3600 sec (1 hour) recording, the file size will be around 700 to 730Mb which is not too big.

By the way, i have an issue with multiple video sources. For example, now i have a built in webcam on my laptop and a secondary USB video source.
I have tried to add two LiveVideo controls. and it only show the webcam source on the second LiveVideo control.

How can i pre define which source i want to view?
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on December 30, 2019, 02:17:28 PM
There is a property VideoDeviceIndex so try changing it on a control that doesn't show video.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on December 30, 2019, 11:01:26 PM
Seems like the next index after 0 has an error. Please see photo.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on December 31, 2019, 02:39:44 AM
The other message states that "Highest possible index is 1", which means that it is detecting 2 cameras.

I have no idea what is causing that error.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on December 31, 2019, 03:19:16 AM
actually this time i run the program on a desktop PC. Only one camera source is available.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on December 31, 2019, 02:48:33 PM
The program doesn't invent things, it is detecting 2 devices which are classified as VideoInputDevices.

You can put a breakpoint, just like in the attached picture, run the program and when it stops at this line then hover the mouse over "ds" to see what devices it is detecting.

Consider replacing all three "ds.Count" with "ds.Length" as the picture shows (or just download the control again).
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on January 01, 2020, 08:29:58 PM
I did as what you advice. Now i'm connecting to a laptop with built in webcam and a usb capture device.
Please see the attachment on what i got so far.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on January 01, 2020, 08:36:00 PM
besides the error i'm facing now, i wonder why the index does not tally with the number of input device?
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on January 01, 2020, 08:53:51 PM
Device ds(1) appears to be identical to ds(0) but it doesn't have the Name and seems to be causing those errors.

It is quite possible a duplicate entry in the registry.

I don't have any suggestion for you as how to resolve it.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on January 01, 2020, 09:04:05 PM
If this is a bug, hopefully Archie can resolve it on the next version.
It's not critical for me to have this control, but it is nice to have it on my HMI.

Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on January 01, 2020, 10:31:39 PM
I don't think that it's a bug.

You can try skipping that index and just use 0 and 2 indexes.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on January 02, 2020, 03:33:15 AM
i mean on the issue of it is not showing the video from all sources.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on January 03, 2020, 12:36:35 AM
The control was updated and replaced to include a possibility of using different video compressors (x264, MJPEG, IYUV, etc) which need to be installed on the PC prior to using the control.

Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on January 03, 2020, 02:53:41 AM
You could try using the attached modified LiveVideo control, with 3 new properties: RecordVideoToFile, RecordVideoFileName and RecordVideoCompressor.

It only does AVI files which will have different size depending on what video compressor you select.

So Godra, should we download from the above quote? Correct me if i'm wrong.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on January 03, 2020, 03:12:12 PM
That's correct.

It's the only post with the control attached so I just keep updating and replacing the file there.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on January 05, 2020, 09:09:40 PM
For those who want to use x264vfw codec, setting it as in the attached picture appears to produce video file size of approximately 11MB per 1 minute of video.

This was true for Video Properties as shown in the 2nd attached picture.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on January 11, 2020, 02:15:51 AM
Thats really helpful
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on February 03, 2020, 08:07:46 PM
Hi Godra,

I just had chance to try the updated control. Unfortunately it cannot work. There is a warning on the control:
An unrecoverable error has occurred.
Object reference not set to an instance of an object.

Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on February 03, 2020, 11:09:20 PM
It could be that you are trying to use the video compressor that's not installed on your PC or something else.

Try using breakpoints similar to what you did previously.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on February 03, 2020, 11:15:24 PM
you are right. it's the video compressor issue.
thanks for your help.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: joko markono on February 03, 2020, 11:31:02 PM
just one more issue. the start recording instruction does not really work.
when i start the app, it starts recording automatically. i have set the RecordVideoToFile as False.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: Godra on February 04, 2020, 01:14:00 PM
Just double check everything again.

The video file is created upon starting the app but doesn't contain any video until recording is enabled.
Title: Re: LIVE VIDEO WITH SAVE FUNCTION
Post by: smithpetermark@gmail.com on February 11, 2024, 02:17:29 AM
I cannot get this control working and in fact now my Solution is throwing errors.

I know this post is old.

I deleted the control and the dll resource and have no errors and will try again.

OK -  reread the instructions and succeeded.  I used the encoder from here btw: https://sourceforge.net/projects/x264vfw/