@@ -18,6 +18,7 @@ class FFcommandExecuteAsyncTask extends AsyncTask<Void, String, CommandResult> i
18
18
private final long timeout ;
19
19
private long startTime ;
20
20
private Process process ;
21
+ private StringBuilder outputStringBuilder = new StringBuilder ();
21
22
private String output = "" ;
22
23
private boolean quitPending ;
23
24
@@ -39,23 +40,27 @@ protected void onPreExecute() {
39
40
40
41
@ Override
41
42
protected CommandResult doInBackground (Void ... params ) {
43
+ CommandResult ret = CommandResult .getDummyFailureResponse ();
42
44
try {
43
45
process = shellCommand .run (cmd , environment );
44
46
if (process == null ) {
45
47
return CommandResult .getDummyFailureResponse ();
46
48
}
47
49
Log .d ("Running publishing updates method" );
48
50
checkAndUpdateProcess ();
49
- return CommandResult .getOutputFromProcess (process );
51
+ ret = CommandResult .getOutputFromProcess (process );
52
+ outputStringBuilder .append (ret .output );
50
53
} catch (TimeoutException e ) {
51
54
Log .e ("FFmpeg binary timed out" , e );
52
- return new CommandResult (false , e .getMessage ());
55
+ ret = new CommandResult (false , e .getMessage ());
56
+ outputStringBuilder .append (ret .output );
53
57
} catch (Exception e ) {
54
58
Log .e ("Error running FFmpeg binary" , e );
55
59
} finally {
56
60
Util .destroyProcess (process );
57
61
}
58
- return CommandResult .getDummyFailureResponse ();
62
+ output = outputStringBuilder .toString ();
63
+ return ret ;
59
64
}
60
65
61
66
@ Override
@@ -68,7 +73,6 @@ protected void onProgressUpdate(String... values) {
68
73
@ Override
69
74
protected void onPostExecute (CommandResult commandResult ) {
70
75
if (ffmpegExecuteResponseHandler != null ) {
71
- output += commandResult .output ;
72
76
if (commandResult .success ) {
73
77
ffmpegExecuteResponseHandler .onSuccess (output );
74
78
} else {
@@ -107,7 +111,7 @@ private void checkAndUpdateProcess() throws TimeoutException, InterruptedExcepti
107
111
return ;
108
112
}
109
113
110
- output += line + "\n " ;
114
+ outputStringBuilder . append ( line ); outputStringBuilder . append ( "\n " ) ;
111
115
publishProgress (line );
112
116
}
113
117
} catch (IOException e ) {
0 commit comments