Ejemplo n.º 1
0
        /// <summary>
        /// Occurs when data is received from the executing application.
        /// </summary>
        private void FFmpeg_DataReceived(object sender, DataReceivedEventArgs e)
        {
            if (e.Data == null)
            {
                if (!isStarted && isFFmpeg)
                {
                    ParseFileInfo();
                }
                return;
            }

            output.AppendLine(e.Data);
            DataReceived?.Invoke(sender, e);

            if (isFFmpeg)
            {
                if (FileStreams == null && (e.Data.StartsWith("Output ") || e.Data.StartsWith("Press [q] to stop")))
                {
                    ParseFileInfo();
                }
                if (e.Data.StartsWith("Press [q] to stop") || e.Data.StartsWith("frame="))
                {
                    isStarted = true;
                }

                if (isStarted && e.Data.StartsWith("frame="))
                {
                    FFmpegStatus ProgressInfo = FFmpegParser.ParseProgress(e.Data);
                    StatusUpdated?.Invoke(this, new StatusUpdatedEventArgs(ProgressInfo));
                }
            }
        }
Ejemplo n.º 2
0
        private void ParseFileInfo()
        {
            TimeSpan fileDuration;

            FileStreams  = FFmpegParser.ParseFileInfo(output.ToString(), out fileDuration);
            FileDuration = fileDuration;
            if (Options.FrameCount > 0)
            {
                FrameCount = Options.FrameCount;
            }
            else if (VideoStream != null)
            {
                FrameCount = (int)(FileDuration.TotalSeconds * VideoStream.FrameRate);
            }
            InfoUpdated?.Invoke(this, new EventArgs());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Occurs when data is received from the executing application.
        /// </summary>
        private void FFmpeg_DataReceived(object sender, DataReceivedEventArgs e)
        {
            if (e.Data == null)
            {
                // We're reading both Output and Error streams, only parse on 2nd null.
                if (!isStarted && encoder != EncoderApp.Other)
                {
                    ParseFileInfo();
                }
                return;
            }

            output.AppendLine(e.Data);
            DataReceived?.Invoke(sender, e);

            if (encoder == EncoderApp.FFmpeg)
            {
                if (FileStreams == null && (e.Data.StartsWith("Output ") || e.Data.StartsWith("Press [q] to stop")))
                {
                    ParseFileInfo();
                }
                if (e.Data.StartsWith("Press [q] to stop") || e.Data.StartsWith("frame="))
                {
                    isStarted = true;
                }

                if (isStarted && e.Data.StartsWith("frame="))
                {
                    FFmpegStatus ProgressInfo = FFmpegParser.ParseFFmpegProgress(e.Data);
                    LastStatusReceived = ProgressInfo;
                    StatusUpdated?.Invoke(this, new StatusUpdatedEventArgs(ProgressInfo));
                }
            }
            else if (encoder == EncoderApp.x264)
            {
                if (!isStarted && e.Data.StartsWith("frames "))
                {
                    isStarted = true;
                }
                else if (isStarted && e.Data.Length == 48)
                {
                    FFmpegStatus ProgressInfo = FFmpegParser.ParseX264Progress(e.Data);
                    LastStatusReceived = ProgressInfo;
                    StatusUpdated?.Invoke(this, new StatusUpdatedEventArgs(ProgressInfo));
                }
            }
        }