Using FFMpeg and Record The Progress of Convertion
Read first
Here
And Here
Let me complete the Missing Part.
public static class Utility
{
public static double TotalDuration;
public static double CurrentDuration;
public static double PercentageOfFinish;
public static string ExtractDuration(string duration)
{
//ex: Duration: 01:30:10.92, start: 0.000000, bitrate: 1084 kb/s
Regex regex = new Regex("[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]");
Match resultmatch = regex.Match(duration);
if (resultmatch.Success)
{
return resultmatch.Value.ToString();
}
return duration;
}
public static double TotalStringToSeconds(string RawDuration)
{
//01:30:10.92
double seconds = 0.0;
int hours = int.Parse(RawDuration.Substring(0, 2));
seconds += Utility.ConvertHoursToSeconds(hours);
int minute=int.Parse(RawDuration.Substring(3, 2));
seconds += Utility.ConvertMinutesToSeconds(minute);
int second = int.Parse(RawDuration.Substring(6, 2));
seconds += second;
int milisecond=int.Parse(RawDuration.Substring(9, 2));
seconds += ConvertMillisecondsToSeconds(milisecond);
return Convert.ToDouble(seconds);
}
public static void synchTotal(string total)
{
TotalDuration = Convert.ToDouble(total);
Logger.Write(TotalDuration.ToString());
}
public static string ExtractTime(string time)
{
//frame= 91 fps= 0 q=31.0 size= 118kB time=3.64 bitrate= 265.4kbits/s
int indexoftime = time.IndexOf("time=");
int indexofbitrate = time.IndexOf("bitrate=");
string extractedTime = time.Substring(indexoftime, indexofbitrate-indexoftime);
extractedTime = extractedTime.Replace("time=", "");
//Regex regex = new Regex("[time=][0-9].[0-9][0-9]");
//Match resultmatch = regex.Match(time);
//if (resultmatch.Success)
//{
// return resultmatch.Value.ToString().Replace("=","");
//}
return extractedTime.Trim();
}
public static double CurrentStringToSeconds(string rawstring)
{
//3.36
//assume it's minutes
return Convert.ToDouble(ConvertMinutesToSeconds(Convert.ToDouble(rawstring)));
}
public static void synchCurrent(string rawstring)
{
//214
CurrentDuration = Convert.ToDouble(rawstring);
PercentageOfFinish = (CurrentDuration/TotalDuration)*100;
Logger.Write(PercentageOfFinish.ToString());
}
public static void synchTextOutput(string text)
{}
#region To seconds
public static double ConvertMillisecondsToSeconds(double milliseconds)
{
return TimeSpan.FromMilliseconds(milliseconds).TotalSeconds;
}
public static double ConvertMinutesToSeconds(double minutes)
{
return TimeSpan.FromMinutes(minutes).TotalSeconds;
}
public static double ConvertHoursToSeconds(double hours)
{
return TimeSpan.FromHours(hours).TotalSeconds;
}
public static double ConvertDaysToSeconds(double days)
{
return TimeSpan.FromDays(days).TotalSeconds;
}
#endregion
}
So actually FFmpeg does log on during conversion but to StandardError.
But one thing to note.. the first time you get the output of how long the duration is.
It can grow, i mean during convertion the duration can grow longer... i found it on wmv files.
I've make the Percentage of Convertion and it can grow more than 100% that's because the time being passed on frame log can Grow more than the duration in seconds.
At the end , it says 'muxed 1.11%' howmany percent
that's the Grow size from the actual one.