Skip to content

Commit 28f88b5

Browse files
committed
Trying to guess FFmpeg process end
1 parent df9dd73 commit 28f88b5

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

FFMpeg.Xamarin/FFMpegLibrary.cs

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ await Task.Run(() =>
216216
}
217217
}
218218

219+
public static string EndOfFFMPEGLine = "final ratefactor:";
220+
219221
private static int _Run(
220222
Context context,
221223
string cmd,
@@ -247,20 +249,41 @@ private static int _Run(
247249
process.Start();
248250

249251

250-
Task.Run(() =>
252+
Task.Run(async () =>
251253
{
252-
using (var reader = process.StandardError)
254+
try
253255
{
254-
string processOutput = "";
255-
do
256+
using (var reader = process.StandardError)
256257
{
257-
var line = reader.ReadLine();
258-
if (line == null)
259-
break;
260-
logger?.Invoke(line);
261-
processOutput += line;
262-
} while (!finished);
263-
error = processOutput;
258+
string processOutput = "";
259+
do
260+
{
261+
var line = reader.ReadLine();
262+
if (line == null)
263+
break;
264+
logger?.Invoke(line);
265+
processOutput += line;
266+
267+
268+
if (line.StartsWith(EndOfFFMPEGLine))
269+
{
270+
// we are assuming that process has finished.. we will exit forcefully
271+
// after 1 minute...
272+
await Task.Delay(TimeSpan.FromMinutes(1));
273+
274+
System.Diagnostics.Debug.WriteLine("Forcing ffmpeg to exit..");
275+
276+
process.Kill();
277+
}
278+
279+
} while (!finished);
280+
error = processOutput;
281+
282+
283+
}
284+
}
285+
catch (Exception ex) {
286+
System.Diagnostics.Debug.WriteLine(ex);
264287
}
265288
});
266289

FFMpeg.Xamarin/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
// You can specify all the values or you can default the Build and Revision Numbers
2727
// by using the '*' as shown below:
2828
// [assembly: AssemblyVersion("1.0.*")]
29-
[assembly: AssemblyVersion("1.0.27.*")]
29+
[assembly: AssemblyVersion("1.0.28.*")]
3030

nuget/Package.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>Xamarin.Android.FFmpeg</id>
5-
<version>1.0.27</version>
5+
<version>1.0.28</version>
66
<title>FFmpeg binding for Xamarin Android</title>
77
<authors>akash.kava</authors>
88
<owners></owners>

0 commit comments

Comments
 (0)