Author Topic: LIVE VIDEO WITH SAVE FUNCTION  (Read 12012 times)

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
LIVE VIDEO WITH SAVE FUNCTION
« on: December 27, 2019, 03:20:21 AM »
Hope to have this tool: https://www.advancedhmi.com/forum/index.php?topic=976.msg5123#msg5123
can be upgraded with save function (e.g. avi, mpeg, etc)

Thanks.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #1 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.
« Last Edit: January 04, 2020, 08:37:38 PM by Godra »

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #2 on: December 29, 2019, 09:39:38 PM »
Thanks Godra. may i know how to start recording using button control?

example: RecordVideoToFile = True


Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #3 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.
« Last Edit: May 10, 2020, 12:04:14 AM by Godra »

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #4 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?
« Last Edit: December 30, 2019, 03:03:29 AM by joko markono »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #5 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.

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #6 on: December 30, 2019, 11:01:26 PM »
Seems like the next index after 0 has an error. Please see photo.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #7 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.
« Last Edit: December 31, 2019, 02:52:00 AM by Godra »

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #8 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.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #9 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).
« Last Edit: December 31, 2019, 03:14:07 PM by Godra »

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #10 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.

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #11 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?

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #12 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.

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #13 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.


Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: LIVE VIDEO WITH SAVE FUNCTION
« Reply #14 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.