Ejemplo n.º 1
0
        void OnEnable()
        {
            m_yuvReader = new YUVReader();

            // launch
            var exec = Path.Combine(Environment.GetEnvironmentVariable(KEY), EXE);
            m_ffmpeg = FFMpegLauncher.Launch(exec, "-i \"{0}\" -f yuv4mpegpipe -", Source);
            if (m_ffmpeg == null)
            {
                Debug.LogWarning("fail to launch ffmpeg");
                return;
            }

            m_stdOutDisposable = m_ffmpeg.StdOut.BeginRead(new Byte[8192], (b, c) => m_yuvReader.Push(new ArraySegment<byte>(b, 0, c)));
            m_stdErrDisposable = m_ffmpeg.StdErr.BeginRead(new Byte[1024], (b, c) => OnRead(m_error, b, c));
        }
Ejemplo n.º 2
0
    void Start()
    {
        material = gameObject.GetComponent <MeshRenderer> ().sharedMaterial;

        if (!File.Exists(FilePath))
        {
            UnityEngine.Debug.Log("No file at given path");
            return;
        }

        var opt = String.Format("-i \"{0}\"", FilePath);

        opt += " -f yuv4mpegpipe";
        opt += " -pix_fmt yuv444p";
//		opt += " -filter:v \"setpts=0.25*PTS\"";
        opt += " -";

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

        info.UseShellExecute        = false;
        info.CreateNoWindow         = true;
        info.RedirectStandardOutput = true;
        info.RedirectStandardError  = true;
        info.StandardErrorEncoding  = Encoding.UTF8;

        _subprocess = Process.Start(info);
        _yuvReader  = new YUVReader();

        _stdout = _subprocess.StandardOutput.BaseStream;
        _stdout.BeginRead(new Byte[8192], (b, c) => _yuvReader.Push(new ArraySegment <byte>(b, 0, c)));

        _stderror = _subprocess.StandardError.BaseStream;
        _stderror.BeginRead(new Byte[1024], (b, c) => ErrorHandling.OnRead(b, c));

        lastFrameNumber = -1;
    }