Skip to content

Commit 665eeaa

Browse files
committed
Only report output location on completion
Instead of previewing the transcode result in a half video or audio viewer, only report where the result was written. In the future there can be a button to launcher a native viewer.
1 parent c714e37 commit 665eeaa

15 files changed

+46
-633
lines changed

app/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ dependencies {
4444
compile 'com.android.support:design:27.0.2'
4545
compile 'com.writingminds:FFmpegAndroid:0.3.2'
4646
compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
47-
compile 'com.android.support:cardview-v7:27.0.2'
4847
compile 'commons-io:commons-io:2.5'
4948
compile group: 'com.google.guava', name: 'guava', version: '20.0'
5049
testCompile 'junit:junit:4.12'

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,6 @@
2020
<category android:name="android.intent.category.LAUNCHER" />
2121
</intent-filter>
2222
</activity>
23-
<activity android:name=".activity.PreviewActivity"
24-
android:screenOrientation="portrait">
25-
26-
</activity>
27-
<activity android:name=".activity.PreviewImageActivity"
28-
android:screenOrientation="portrait">
29-
30-
</activity>
31-
<activity android:name=".activity.AudioPreviewActivity"
32-
android:screenOrientation="portrait">
33-
34-
</activity>
3523
</application>
3624

3725
</manifest>

app/src/main/java/protect/videotranscoder/FFmpegResponseHandler.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.app.ProgressDialog;
44
import android.content.Context;
5-
import android.content.Intent;
65
import android.util.Log;
76

87
import com.github.hiteshsondhi88.libffmpeg.ExecuteBinaryResponseHandler;
@@ -12,29 +11,31 @@ public class FFmpegResponseHandler extends ExecuteBinaryResponseHandler
1211
private static final String TAG = "VideoTranscoder";
1312

1413
private final Context _context;
15-
private final Intent _intentToLaunch;
1614
private final long _durationMs;
1715
private final ProgressDialog _progressDialog;
16+
private final ResultCallbackHandler<Boolean> _resultHandler;
1817

19-
public FFmpegResponseHandler(Context context, Intent intent, long durationMs, ProgressDialog progressDialog)
18+
public FFmpegResponseHandler(Context context, long durationMs, ProgressDialog progressDialog,
19+
ResultCallbackHandler<Boolean> resultHandler)
2020
{
2121
_context = context;
22-
_intentToLaunch = intent;
2322
_durationMs = durationMs;
2423
_progressDialog = progressDialog;
24+
_resultHandler = resultHandler;
2525
}
2626

2727
@Override
2828
public void onFailure(String s)
2929
{
3030
Log.d(TAG, "Failed with output : " + s);
31+
_resultHandler.onResult(false);
3132
}
3233

3334
@Override
3435
public void onSuccess(String s)
3536
{
3637
Log.d(TAG, "Success with output : " +s);
37-
_context.startActivity(_intentToLaunch);
38+
_resultHandler.onResult(true);
3839
}
3940

4041
@Override

app/src/main/java/protect/videotranscoder/activity/AudioPreviewActivity.java

Lines changed: 0 additions & 120 deletions
This file was deleted.

app/src/main/java/protect/videotranscoder/activity/MainActivity.java

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,39 @@ public void onClick(DialogInterface dialog, int which)
394394

395395
}
396396

397+
private ResultCallbackHandler<Boolean> _transcodeResultHandler = new ResultCallbackHandler<Boolean>()
398+
{
399+
@Override
400+
public void onResult(Boolean result)
401+
{
402+
String message;
403+
404+
if(result)
405+
{
406+
message = getResources().getString(R.string.transcodeSuccess, filePath);
407+
}
408+
else
409+
{
410+
message = getResources().getString(R.string.transcodeFailed);
411+
}
412+
413+
new AlertDialog.Builder(MainActivity.this)
414+
.setMessage(message)
415+
.setCancelable(true)
416+
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
417+
{
418+
public void onClick(DialogInterface dialog, int which)
419+
{
420+
dialog.dismiss();
421+
}
422+
})
423+
.show();
424+
425+
videoView.seekTo(stopPosition);
426+
videoView.start();
427+
}
428+
};
429+
397430
/**
398431
* Command for cutting video
399432
*/
@@ -422,10 +455,7 @@ private void executeCutVideoCommand(int startMs, int endMs)
422455

423456
final String[] complexCommand = {"-ss", "" + startMs / 1000, "-y", "-i", yourRealPath, "-t", "" + (endMs - startMs) / 1000,"-vcodec", "mpeg4", "-b:v", "2097152", "-b:a", "48000", "-ac", "2", "-ar", "22050", filePath};
424457

425-
Intent successIntent = new Intent(MainActivity.this, PreviewActivity.class);
426-
successIntent.putExtra(FILEPATH, filePath);
427-
428-
FFmpegResponseHandler handler = new FFmpegResponseHandler(this, successIntent, durationMs, progressDialog);
458+
FFmpegResponseHandler handler = new FFmpegResponseHandler(this, durationMs, progressDialog, _transcodeResultHandler);
429459
FFmpegUtil.call(complexCommand, handler);
430460

431461
stopPosition = videoView.getCurrentPosition(); //stopPosition is an int
@@ -459,10 +489,7 @@ private void executeCompressCommand()
459489
filePath = dest.getAbsolutePath();
460490
String[] complexCommand = {"-y", "-i", yourRealPath, "-s", "160x120", "-r", "25", "-vcodec", "mpeg4", "-b:v", "150k", "-b:a", "48000", "-ac", "2", "-ar", "22050", filePath};
461491

462-
Intent successIntent = new Intent(MainActivity.this, PreviewActivity.class);
463-
successIntent.putExtra(FILEPATH, filePath);
464-
FFmpegResponseHandler handler = new FFmpegResponseHandler(this, successIntent, durationMs, progressDialog);
465-
492+
FFmpegResponseHandler handler = new FFmpegResponseHandler(this, durationMs, progressDialog, _transcodeResultHandler);
466493
FFmpegUtil.call(complexCommand, handler);
467494

468495
stopPosition = videoView.getCurrentPosition();
@@ -508,10 +535,7 @@ private void extractImagesVideo(int startMs, int endMs)
508535

509536
String[] complexCommand = {"-y", "-i", yourRealPath, "-an", "-r", "1", "-ss", "" + startMs / 1000, "-t", "" + (endMs - startMs) / 1000, dest.getAbsolutePath()};
510537

511-
Intent successIntent = new Intent(MainActivity.this, PreviewImageActivity.class);
512-
successIntent.putExtra(FILEPATH, filePath);
513-
FFmpegResponseHandler handler = new FFmpegResponseHandler(this, successIntent, durationMs, progressDialog);
514-
538+
FFmpegResponseHandler handler = new FFmpegResponseHandler(this, durationMs, progressDialog, _transcodeResultHandler);
515539
FFmpegUtil.call(complexCommand, handler);
516540

517541
stopPosition = videoView.getCurrentPosition(); //stopPosition is an int
@@ -544,10 +568,7 @@ private void extractAudioVideo()
544568

545569
String[] complexCommand = {"-y", "-i", yourRealPath, "-vn", "-ar", "44100", "-ac", "2", "-b:a", "256k", "-f", "mp3", filePath};
546570

547-
Intent successIntent = new Intent(MainActivity.this, AudioPreviewActivity.class);
548-
successIntent.putExtra(FILEPATH, filePath);
549-
FFmpegResponseHandler handler = new FFmpegResponseHandler(this, successIntent, durationMs, progressDialog);
550-
571+
FFmpegResponseHandler handler = new FFmpegResponseHandler(this, durationMs, progressDialog, _transcodeResultHandler);
551572
FFmpegUtil.call(complexCommand, handler);
552573

553574
stopPosition = videoView.getCurrentPosition(); //stopPosition is an int

0 commit comments

Comments
 (0)