Exemplo n.º 1
0
        public FFmpegPipe(string name, int width, int height, int framerate, Codec codec)
        {
            PupilGazeTracker pupilTracker = PupilGazeTracker.Instance;

            name = "Unity_" + PupilSettings.Instance.currentCamera.name;
            string date = DateTime.Now.ToString("yyyy_MM_dd");
            string path = Application.dataPath + "/" + date;


            if (PupilSettings.Instance.recorder.isCustomPath)
            {
                path = PupilSettings.Instance.recorder.filePath + "/" + date;
            }

            path = path.Replace("Assets/", "");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            UnityEngine.Debug.Log(path);
            PupilTools.StartPupilServiceRecording(path);

            Thread.Sleep(200);             //Waiting for Pupil Service to create the incremented folder

            path += "/" + GetLastIncrement(path);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            Filename = "\"" + path + "/" + name + GetSuffix(codec) + "\"";

            var opt = "-y -f rawvideo -vcodec rawvideo -pixel_format rgb24";

            opt += " -video_size " + width + "x" + height;
            opt += " -framerate " + framerate;
            opt += " -loglevel warning -i - " + GetOptions(codec);
            opt += " " + Filename;

            var info = new ProcessStartInfo(FFmpegConfig.BinaryPath, opt);

            info.UseShellExecute        = false;
            info.CreateNoWindow         = true;
            info.RedirectStandardInput  = true;
            info.RedirectStandardOutput = true;
            info.RedirectStandardError  = true;

            FilePath = path;

            _subprocess = Process.Start(info);
            _stdin      = new BinaryWriter(_subprocess.StandardInput.BaseStream);
        }