Browse files

More reliable detection of successful encode

  • Loading branch information...
1 parent 6695f26 commit fdcc00d8bf1caedb29ea32283ce117b2f72d87c1 @orryverducci committed May 26, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 SmoothTranscode/ffmpeg.cs
View
9 SmoothTranscode/ffmpeg.cs
@@ -38,7 +38,7 @@ public class ffmpeg
private int pass = 1;
private static TimeSpan trimstart = new TimeSpan(0, 0, 0);
private static TimeSpan trimlength = new TimeSpan(0, 0, 0);
- private int percentage;
+ private bool successful = false;
private string ffmpegOutput;
private bool cancelled = false;
public delegate void FinishedEventHandler(object sender, FinishedEventArgs cmdoutput);
@@ -152,6 +152,7 @@ public void ConvertFile()
private void ParseProgress(object sender, DataReceivedEventArgs e)
{
+ int percentage;
string fps;
string bitrate;
TimeSpan currentTime;
@@ -185,6 +186,10 @@ private void ParseProgress(object sender, DataReceivedEventArgs e)
ProgressUpdate(this, new ProgressEventArgs(percentage, fps, bitrate, pass));
}
}
+ else if (e.Data.Contains("global headers:"))
+ {
+ successful = true;
+ }
}
else
{
@@ -283,7 +288,7 @@ protected virtual void FfmpegProcessExited(object sender, EventArgs e)
logging.finishLog();
if (conversionEnded != null)
{
- if (percentage < 100 && !cancelled)
+ if (!successful && !cancelled)
conversionEnded(this, new FinishedEventArgs(true, ffmpegOutput));
else
conversionEnded(this, new FinishedEventArgs(false, ""));

0 comments on commit fdcc00d

Please sign in to comment.