Announcement

Collapse
No announcement yet.

Systematically capturing webcam footage

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Systematically capturing webcam footage

    I have a customer who is moving (metal working shop, making curtain rods for interior designers) and in the past, due to the occasional complaint about missing pieces in shipping, they started filming the packaging, where they then take the SD card out, put it in a computer in the office, and copy the file to a USB 3.0 HDD. I replaced the PC's reader with a external USB 3.0 reader and it really flies, hardly takes any time compared to how it used to be. It's done with an HD handheld camera but requires two employees, and that's taking someone away from doing work. Also, these SD cards, even though they're full sized, they're used so often they wear out in only a few weeks.

    In his new place, he wants to automate the system. I've been going through my head so far and this is what I have:

    Mount an NUC with a 1080p or 4k webcam above the table where they box everything. Put up a small tv in front with the nuc hooked to it. Next is where i'm still working out. What I have is, make a simple program in c#.net or vb.net where the order number is typed in and used in making the command line for the proper folders and parameters for VLC to capture the video to a NAS on the network. I've already been playing around with FFMPEG dshow, but it doesn't have a native output screen (though it can pipe ffplay, it doesn't have as good as an interface).

    Since it's a mapped drive, it has to temp write the file locally and copy the file over the network. If it's not copied completely before another order starts, this might cause problems. It did when I was testing the capture concept on a laptop. Mind you it was a shitty little 10.1" atom laptop and the results were mixed.

    Anyone have any alternatives? I've been reading through documentation about dplay capture libraries with c#.net but it's been confusing. I've done tons of searching and researching of capture programs, but theyre all complex, or too simple (and lack the command line properties I need).

    anyone have any other ideas or better yet something I haven't even come near considering? Keep in mind HAS to have the order number as a file/folder
    Cap Datasheet Depot: http://www.paullinebarger.net/DS/
    ^If you have datasheets not listed PM me

    #2
    Re: Systematically capturing webcam footage

    Never dealt with C#, only with C and C++ and not doing this.
    Why webcam, if you can do this with IP camera and just record on network share?
    Useful conversions. I don't "speak" imperial. Please use metric, if you want to address me.
    1km=1000m=100000cm, 1inch=2.54cm, 1mile=1609.344meters, 1ft=30.48cm 1gal(US)=3.785liters, 1lb=453grams, 1oz=28.34grams

    Comment


      #3
      Re: Systematically capturing webcam footage

      Originally posted by televizora View Post
      Never dealt with C#, only with C and C++ and not doing this.
      Why webcam, if you can do this with IP camera and just record on network share?
      If you can do c++, c# should be a cakewalk

      It needs to have a marker some way indicating the order number, and look can be looked up easily by that number on the nas
      Cap Datasheet Depot: http://www.paullinebarger.net/DS/
      ^If you have datasheets not listed PM me

      Comment


        #4
        Re: Systematically capturing webcam footage

        there is loads of webcam software,
        i dont use any, but "cheese" is supposed to be good

        Comment


          #5
          Re: Systematically capturing webcam footage

          Originally posted by Uranium-235 View Post
          If you can do c++, c# should be a cakewalk

          It needs to have a marker some way indicating the order number, and look can be looked up easily by that number on the nas
          My dear, I use C and C++ for assembly and other stuff. Never dealt with video capture libraries, stuff like this or even GUI. And the other is web programming with JS and PHP. You want a piece of software that will make the camera record after inputting a file name and pressing a start button. I see what you want. Not gonna happen the way you want it, unless you program it. I deal with system administration and scripting, not the right person.
          BUT
          You can write down a simple batch, using the FFMPEG parameters.
          Code:
           ffmpeg -f dshow -i video="Integrated Camera":audio="Microphone name here" out.mp4
          Just make it fancy, ask the user to input variable. Pass it as a parameter for the FFMPEG.
          At the end, if you don't want preset time, just terminate it. You can even specify a PATH via the parameters.
          So, your task seem trivial if you are satisfied with this.
          I believe that it wont be hard for you to piece together such a batch file.
          I still don't like the idea of Webcam, but if you use IP CCTV camera, I don't see how you can do it with reasonable amount of effort.
          And specify normal codec. Not something like MPEG2 or MPEG4, unless you want huge files.
          The best thing is that there are some tools, which can help you but the bat file in .exe container.
          And here is how to gracefully terminate FFMPEG in Windows
          https://stackoverflow.com/questions/...ffmpeg-windows
          Last edited by televizora; 11-27-2020, 11:29 AM.
          Useful conversions. I don't "speak" imperial. Please use metric, if you want to address me.
          1km=1000m=100000cm, 1inch=2.54cm, 1mile=1609.344meters, 1ft=30.48cm 1gal(US)=3.785liters, 1lb=453grams, 1oz=28.34grams

          Comment


            #6
            Re: Systematically capturing webcam footage

            If you do something like this...
            controlbat.bat

            Code:
            set var1=7
            start /min cmd /k bat2
            pause
            taskkill /fi "WindowTitle eq Killer"
            pause
            and the second bat is
            bat2.bat
            Code:
            echo variable is %var1%
            The second window with ffmpeg will get the name variable.
            The first window after pressing any key will kill the mpeg window
            Then it will terminate itself as well

            Because taskkill is not gracefully sending signal to the second window, this can corrupt the file, if it's in the fancy formats, not plain .avi
            I will experiment with extracting pid, setting it as variable and then using sendsignal or other tool.
            The simplicity is that when the first bat calls the second, it passes the vabiable, minimizes the window and then returns the control to the first, from which you can terminate the second window and then the first.
            If you try this, you will see that echo-ing the var1 from the bat2 window called killer works.
            Also, you will potentially have to deal with unhappy Antivirus programs. I have a file, that pings and logs to file and Avast always tries to block it.
            Add user input with setp=ordernumer digits only is the best way to go and you are ready.
            I don't have webcam to test it with ffmpeg.
            Last edited by televizora; 11-27-2020, 01:31 PM.
            Useful conversions. I don't "speak" imperial. Please use metric, if you want to address me.
            1km=1000m=100000cm, 1inch=2.54cm, 1mile=1609.344meters, 1ft=30.48cm 1gal(US)=3.785liters, 1lb=453grams, 1oz=28.34grams

            Comment


              #7
              Re: Systematically capturing webcam footage

              yeah as I said I tried ffmpeg, but I want to show the capture live. So far the only thing i've had SOME success with is VLC, that lets you specify things like bitrate in the output. I was just wondering if anyone knew a better way than both

              Yeah ffmpeg does tend to corrupt if it's killed as a process. The only real option to to send control+c to the window

              Damn, you should probably change "student tech" to "professional tech". You have more skills than most of us (except like surface level soldering stuff). Do you know .net? I'll might be able to get him to pay. I hear dshow has a library for .net
              Cap Datasheet Depot: http://www.paullinebarger.net/DS/
              ^If you have datasheets not listed PM me

              Comment


                #8
                Re: Systematically capturing webcam footage

                Originally posted by Uranium-235 View Post
                yeah as I said I tried ffmpeg, but I want to show the capture live. So far the only thing i've had SOME success with is VLC, that lets you specify things like bitrate in the output. I was just wondering if anyone knew a better way than both
                Yeah ffmpeg does tend to corrupt if it's killed as a process. The only real option to to send control+c to the window
                Damn, you should probably change "student tech" to "professional tech". You have more skills than most of us (except like surface level soldering stuff). Do you know .net? I'll might be able to get him to pay. I hear dshow has a library for .net
                Taskkill /f kills the process not gracefully. Without this switch the process is kindly asked to stop what it is doing and terminate.
                No, I don't deal with GUI programming. Well, I can read and modify something, if I need to do so.
                What I write are scripts, usually to automate tedious tasks.
                There are some external programs like I said early. Which can send ctrl+c.
                Also, using SDL there is a way to record and preview simultaneously.
                Interesting question you have... You will make me install Visual studio, you know...
                Maybe will think of something...
                Last edited by televizora; 11-28-2020, 06:21 AM.
                Useful conversions. I don't "speak" imperial. Please use metric, if you want to address me.
                1km=1000m=100000cm, 1inch=2.54cm, 1mile=1609.344meters, 1ft=30.48cm 1gal(US)=3.785liters, 1lb=453grams, 1oz=28.34grams

                Comment


                  #9
                  Re: Systematically capturing webcam footage

                  Gui is pretty easy. It's basically drag and drop in vs, but can be manipulated or created programmatically
                  Cap Datasheet Depot: http://www.paullinebarger.net/DS/
                  ^If you have datasheets not listed PM me

                  Comment


                    #10
                    Re: Systematically capturing webcam footage

                    Originally posted by Uranium-235 View Post
                    Gui is pretty easy. It's basically drag and drop in vs, but can be manipulated or created programmatically
                    I might have something for you, if you can wait. I'm up to the part with the order number and digging how to parse .ini file or something like this, so you can set the path to your network share. I hope that order number is simple digit or at most text+digit combo? Worst case scenario - you end up with text field for the network share path. Or browse box.
                    You may make me learn some C#
                    Last edited by televizora; 11-28-2020, 04:53 PM.
                    Useful conversions. I don't "speak" imperial. Please use metric, if you want to address me.
                    1km=1000m=100000cm, 1inch=2.54cm, 1mile=1609.344meters, 1ft=30.48cm 1gal(US)=3.785liters, 1lb=453grams, 1oz=28.34grams

                    Comment


                      #11
                      Re: Systematically capturing webcam footage

                      The number isn't a big deal. I know some c#.net but nothing incredibly advanced. I can check the field for a number if you give me the source.

                      What libraries are you using?

                      Maybe you can add this to your already highly developed technical repertoire
                      Cap Datasheet Depot: http://www.paullinebarger.net/DS/
                      ^If you have datasheets not listed PM me

                      Comment


                        #12
                        Re: Systematically capturing webcam footage

                        Originally posted by Uranium-235 View Post
                        The number isn't a big deal. I know some c#.net but nothing incredibly advanced. I can check the field for a number if you give me the source.
                        What libraries are you using?
                        Maybe you can add this to your already highly developed technical repertoire
                        I specially am just trying to modify this example, already made by someone.
                        I think that it can be ideal for you. The things that bother me are to parse config and etc. I have not dealt with c# for years, honestly.
                        Trying hard to remember. Perhaps you are better at C# than me.
                        This is the example - https://github.com/mesta1/Recording-video-with-c-
                        OOP really annoys me. In the example you have preview, camera selection, snapshot. I think that it's perfect for you.
                        Have to use method to return the contents of the box to variable and then pass it to the content writer as file name in the box. Nice.
                        Last edited by televizora; 11-29-2020, 09:35 AM.
                        Useful conversions. I don't "speak" imperial. Please use metric, if you want to address me.
                        1km=1000m=100000cm, 1inch=2.54cm, 1mile=1609.344meters, 1ft=30.48cm 1gal(US)=3.785liters, 1lb=453grams, 1oz=28.34grams

                        Comment


                          #13
                          Re: Systematically capturing webcam footage

                          Well, here is your app with one field for the order number.
                          Then inserts it as a file name when you click on start recording->browse.
                          Also, app.config sets default path for the dialogue.
                          https://www96.zippyshare.com/v/cljmIEcW/file.html
                          I still hate C#, you know...

                          My changes app.config
                          Code:
                          <?xml version="1.0" encoding="utf-8" ?>
                          <configuration>
                            <startup> 
                              <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
                            </startup>
                          	<appSettings>
                          	<add key="PATH" value="C:\BAD"/>
                          	</appSettings>
                          </configuration>
                          Mainwindow.xaml
                          Code:
                              <TextBox x:Name="p1" Grid.Column="4" HorizontalAlignment="Left" Height="22" Margin="259,6,0,0" TextWrapping="Wrap" 
                                     VerticalAlignment="Top" Width="244" RenderTransformOrigin="0.497,1.333" Grid.Row="2"
                                     Text="{Binding order}"/>
                                <Label Content="Order" Grid.Column="4" HorizontalAlignment="Left" Margin="211,5,0,0" Grid.Row="2" VerticalAlignment="Top" RenderTransformOrigin="0.667,-0.033" Width="43"/>
                          MainWindowModel.cs
                          Code:
                          using System.Configuration;
                          Code:
                              public string order
                              {
                                get { return _order; }
                                set { Set(ref _order, value); }
                              }
                              string path= ConfigurationManager.AppSettings["PATH"];
                          Code:
                              private void StartRecording()
                              {
                                var dialog = new SaveFileDialog();
                          [B]      dialog.FileName = order;
                                dialog.InitialDirectory = path;[/B]
                                dialog.DefaultExt = ".avi";
                                dialog.AddExtension = true;
                          You need to add AForge for it to work. It should ask you.
                          Test it with webcam. Mine, on my laptop is not working. Have no available cam around.
                          Last edited by televizora; 11-29-2020, 11:14 AM.
                          Useful conversions. I don't "speak" imperial. Please use metric, if you want to address me.
                          1km=1000m=100000cm, 1inch=2.54cm, 1mile=1609.344meters, 1ft=30.48cm 1gal(US)=3.785liters, 1lb=453grams, 1oz=28.34grams

                          Comment


                            #14
                            Re: Systematically capturing webcam footage

                            AForge, fascinating. Never ran over that in my search

                            I've tried to download it, but zippyshare always brings up ads :/

                            Like, if I click on anything

                            You would be bored by C#, but it also open up opportunity with someone that has skills like yours. If you were able to make this, I can promise you, that in a day, you are more skilled than me in three weeks of research and testing
                            Cap Datasheet Depot: http://www.paullinebarger.net/DS/
                            ^If you have datasheets not listed PM me

                            Comment


                              #15
                              Re: Systematically capturing webcam footage

                              and if this works like I need it too, I will pay you
                              Cap Datasheet Depot: http://www.paullinebarger.net/DS/
                              ^If you have datasheets not listed PM me

                              Comment


                                #16
                                Re: Systematically capturing webcam footage

                                Originally posted by Uranium-235 View Post
                                I've tried to download it, but zippyshare always brings up ads :/
                                Install AdBlock. Cant upload it here, because of file limits.
                                Next time will use GoogleDrive. And in case of NUC, get something decent that has the capacity to encode video without lagging.
                                AForge can be installed witn NuGet. Contains FFMPEG. We need something to encode the video.
                                If everything is OK and camera is detected, it will bring you preview and ability to record.
                                Path is inside app.config xml file. The app looks inside the file and looks for the value of the Order field.
                                Uses Order=filename, location = path from the xml as default path.
                                I don't like the idea do make it record directly without file dialog, because if the drive is unavailable(net drive) or full,
                                you will need to deal with this kinds of exceptions. And if the exception is not correctly handled, the app may stop working/fail with unknown
                                reason. You need to install reference to ConfigurationManager, to be able to parse XML config file. Parsing pure INI can be PIA, but having XML I don't think you will need it.
                                So instead of manually browsing path and filename, just write order name in the box, when you click StartRec, it will open the File browse dialog with the default path from the XML and as file name the name from the box.|
                                So, just change the default path to the network drive you will map. It would be good if you create an user account on the "server" with password, enable password protected sharing and map the drive with credentials. To be sure that if somebody else is connected to the network, for example Wi-Fi he won't be able to accidentally access or delete stuff. Sharing without password protection or permissions is evil, waiting to bite your ass.
                                Last edited by televizora; 11-30-2020, 03:02 AM.
                                Useful conversions. I don't "speak" imperial. Please use metric, if you want to address me.
                                1km=1000m=100000cm, 1inch=2.54cm, 1mile=1609.344meters, 1ft=30.48cm 1gal(US)=3.785liters, 1lb=453grams, 1oz=28.34grams

                                Comment


                                  #17
                                  Re: Systematically capturing webcam footage

                                  You also have compiled app in the debug folder. You can run the exe right away.
                                  No need to compile it at all.
                                  Also. If the PATH in the config does not exist(net problem, disconnected network drive, shared directory not available) the app will crash.
                                  To fix this we need to put this code. Replace with error message of your choice.
                                  It will tell you that there is error in the config, but will allow you to continue with default path C:\
                                  To check if order is empty and notify, but continue with default name "order" add the second
                                  These lines are to avoid unwanted exceptions.
                                  Code:
                                        if (!Directory.Exists(path))
                                        {
                                          MessageBox.Show("Path does not exist, check CONFIG");
                                          dialog.InitialDirectory = @"C:\";
                                  
                                        }
                                        if(string.IsNullOrEmpty(order))
                                        {
                                          MessageBox.Show("Order name not entered! Continuing with default name");
                                          dialog.FileName = "order";
                                        }
                                  To handle error, where the recording is not started, but you try to stop it we need to add this
                                  Code:
                                      private void StopRecording()
                                      {
                                        [b] if (_recording == false)
                                        {
                                          MessageBox.Show("Recording is not started");
                                          return;
                                        }
                                        [/b]
                                        _recording = false;
                                        _writer.Close();
                                        _writer.Dispose();
                                      }
                                  I think that this handles most exceptions. And I have just increased my level of proficiency in C# with one point.
                                  If you don't feel like installing VisualStudio, I can compile the modified version.
                                  Last edited by televizora; 11-30-2020, 06:42 AM.
                                  Useful conversions. I don't "speak" imperial. Please use metric, if you want to address me.
                                  1km=1000m=100000cm, 1inch=2.54cm, 1mile=1609.344meters, 1ft=30.48cm 1gal(US)=3.785liters, 1lb=453grams, 1oz=28.34grams

                                  Comment


                                    #18
                                    Re: Systematically capturing webcam footage

                                    If you cant download from zippyshare, here is the link. I forgot this. To google drive
                                    https://drive.google.com/file/d/1CG4...ew?usp=sharing
                                    Useful conversions. I don't "speak" imperial. Please use metric, if you want to address me.
                                    1km=1000m=100000cm, 1inch=2.54cm, 1mile=1609.344meters, 1ft=30.48cm 1gal(US)=3.785liters, 1lb=453grams, 1oz=28.34grams

                                    Comment


                                      #19
                                      Re: Systematically capturing webcam footage

                                      Is it .h264? if it's a single setting I make in a config file or in a code line just tell me where
                                      I'll play around with it a bit, thank you for this!
                                      Cap Datasheet Depot: http://www.paullinebarger.net/DS/
                                      ^If you have datasheets not listed PM me

                                      Comment


                                        #20
                                        Re: Systematically capturing webcam footage

                                        Originally posted by Uranium-235 View Post
                                        Is it .h264?
                                        MPEG4 MP4. No codec config at the moment. If you make me modify to select codec, you should buy at least a beer. Haha.
                                        Here is your codec. Now officially you owe me at least a beer.
                                        _writer.Open(dialog.FileName, (int)Math.Round(Image.Width, 0), (int)Math.Round(Image.Height, 0),25, VideoCodec.H264);
                                        Without it, it records using MPEG4 MP4. Consider your hardware. H264 requires more processing power.
                                        Also, you can change the default file extension. It will use codec appropriately to the extension.

                                        Overall bit rate : 1 487 kb/s
                                        Writing application : Lavf57.56.100

                                        Format : MPEG-4 Visual
                                        Format profile : Simple@L1
                                        Format settings, Matrix : Default (H.263)
                                        Codec ID : FMP4
                                        Frame rate : 25.000 FPS
                                        Color space : YUV
                                        Chroma subsampling : 4:2:0
                                        Bit depth : 8 bits
                                        Scan type : Progressive
                                        Compression mode : Lossy
                                        Bits/(Pixel*Frame) : 0.056
                                        Last edited by televizora; 11-30-2020, 09:30 AM.
                                        Useful conversions. I don't "speak" imperial. Please use metric, if you want to address me.
                                        1km=1000m=100000cm, 1inch=2.54cm, 1mile=1609.344meters, 1ft=30.48cm 1gal(US)=3.785liters, 1lb=453grams, 1oz=28.34grams

                                        Comment

                                        Working...
                                        X