// Creates a YUVReader and FFMpegLauncher to start playback.
        // If Source is specified in the Inspector, OnEnable will call Initialize and playback will
        // start immediately. Otherwise it can be called manually to start playback on command.
        public void Initialize(string Source)
        {
            m_yuvReader = new YUVReader();

            // launch
            var exec = Path.Combine(Environment.GetEnvironmentVariable(KEY), EXE);

            m_ffmpeg = FFMpegLauncher.Launch(exec, 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));
        }
 void OnDisable()
 {
     Debug.Log("kill");
     if (m_ffmpeg != null)
     {
         m_ffmpeg.Dispose();
         m_ffmpeg = null;
     }
     if (m_stdOutDisposable != null)
     {
         m_stdOutDisposable.Dispose();
         m_stdOutDisposable = null;
     }
     if (m_stdErrDisposable != null)
     {
         m_stdErrDisposable.Dispose();
         m_stdErrDisposable = null;
     }
 }