Beispiel #1
0
    // constructor ----------------------------------

    public WebcamFfmpeg(Webcam.Action action, UtilAll.OperatingSystems os, string videoDevice, string videoDeviceResolution, string videoDeviceFramerate)
    {
        this.action                = action;
        this.os                    = os;
        this.videoDevice           = videoDevice;
        this.videoDeviceResolution = videoDeviceResolution;
        this.videoDeviceFramerate  = videoDeviceFramerate;

        if (action == Webcam.Action.CAPTURE)
        {
            executable = "ffmpeg";
            if (os == UtilAll.OperatingSystems.WINDOWS)
            {
                executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffmpeg.exe");
            }
            if (os == UtilAll.OperatingSystems.MACOSX)
            {
                executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffmpeg");
            }
        }
        else         // PLAYPREVIEW || PLAYFILE
        {
            executable = "ffplay";
            if (os == UtilAll.OperatingSystems.WINDOWS)
            {
                executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffplay.exe");
            }
            if (os == UtilAll.OperatingSystems.MACOSX)
            {
                executable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffplay");
            }
        }

        Running = false;
    }
Beispiel #2
0
    public FfmpegCapture(string[] args)
    {
        if (args.Length != 1)
        {
            Console.WriteLine("Need to pass the videoDevice");
            return;
        }

        os          = UtilAll.GetOSEnum();
        videoDevice = args[0];

        if (os == UtilAll.OperatingSystems.WINDOWS)
        {
            captureExecutable = System.IO.Path.Combine(Util.GetPrefixDir(), "bin/ffmpeg.exe");
        }

        process = new Process();
        List <string> parameters = createParametersOnlyCapture();
        //List<string> parameters = createParametersCaptureAndDelayedView();
        bool success = ExecuteProcess.RunAtBackground(ref process, captureExecutable, parameters,
                                                      true, false, true); //createNoWindow, useShellExecute, redirectInput

        if (!success)
        {
            streamWriter = null;
            process      = null;
            //return new Result (false, "", programFfmpegNotInstalled);
            return;
        }

        processID    = process.Id;
        streamWriter = process.StandardInput;
        Running      = true;

        Console.WriteLine("Recording 5 seconds ...");
        for (int countA = 4; countA >= 0; countA--)
        {
            System.Threading.Thread.Sleep(1000);
            Console.WriteLine(countA.ToString());
        }

        int sessionID = 0;

        Constants.TestTypes testType = Constants.TestTypes.RUN;
        int testID = 1;

        ExitAndFinish(sessionID, testType, testID);

        Console.WriteLine("Recorded, copied, and deleted ok. Now we are going to play it");

        PlayFile(Util.GetVideoFileName(sessionID, testType, testID));

        //return new Result (true, "");
    }
Beispiel #3
0
 public WebcamManage()
 {
     os            = UtilAll.GetOSEnum();
     ReallyStarted = false;
 }