Skip to content

Commit

Permalink
Trying to guess FFmpeg process end
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Aug 19, 2016
1 parent df9dd73 commit 28f88b5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
45 changes: 34 additions & 11 deletions FFMpeg.Xamarin/FFMpegLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ await Task.Run(() =>
}
}

public static string EndOfFFMPEGLine = "final ratefactor:";

private static int _Run(
Context context,
string cmd,
Expand Down Expand Up @@ -247,20 +249,41 @@ private static int _Run(
process.Start();


Task.Run(() =>
Task.Run(async () =>
{
using (var reader = process.StandardError)
try
{
string processOutput = "";
do
using (var reader = process.StandardError)
{
var line = reader.ReadLine();
if (line == null)
break;
logger?.Invoke(line);
processOutput += line;
} while (!finished);
error = processOutput;
string processOutput = "";
do
{
var line = reader.ReadLine();
if (line == null)
break;
logger?.Invoke(line);
processOutput += line;
if (line.StartsWith(EndOfFFMPEGLine))
{
// we are assuming that process has finished.. we will exit forcefully
// after 1 minute...
await Task.Delay(TimeSpan.FromMinutes(1));
System.Diagnostics.Debug.WriteLine("Forcing ffmpeg to exit..");
process.Kill();
}
} while (!finished);
error = processOutput;
}
}
catch (Exception ex) {
System.Diagnostics.Debug.WriteLine(ex);
}
});

Expand Down
2 changes: 1 addition & 1 deletion FFMpeg.Xamarin/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.27.*")]
[assembly: AssemblyVersion("1.0.28.*")]

2 changes: 1 addition & 1 deletion nuget/Package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Xamarin.Android.FFmpeg</id>
<version>1.0.27</version>
<version>1.0.28</version>
<title>FFmpeg binding for Xamarin Android</title>
<authors>akash.kava</authors>
<owners></owners>
Expand Down

0 comments on commit 28f88b5

Please sign in to comment.