diff --git a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java index a0f26a9..27df0d8 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java +++ b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java @@ -69,6 +69,7 @@ public class VideoHandleActivity extends AppCompatActivity implements View.OnCli findViewById(R.id.btn_combine_video).setOnClickListener(this); findViewById(R.id.btn_play_video).setOnClickListener(this); findViewById(R.id.btn_multi_video).setOnClickListener(this); + findViewById(R.id.btn_reverse_video).setOnClickListener(this); } private void setVisible() { @@ -82,6 +83,7 @@ public class VideoHandleActivity extends AppCompatActivity implements View.OnCli findViewById(R.id.btn_combine_video).setVisibility(View.VISIBLE); findViewById(R.id.btn_play_video).setVisibility(View.VISIBLE); findViewById(R.id.btn_multi_video).setVisibility(View.VISIBLE); + findViewById(R.id.btn_reverse_video).setVisibility(View.VISIBLE); } private void setGone() { @@ -95,6 +97,7 @@ public class VideoHandleActivity extends AppCompatActivity implements View.OnCli findViewById(R.id.btn_combine_video).setVisibility(View.GONE); findViewById(R.id.btn_play_video).setVisibility(View.GONE); findViewById(R.id.btn_multi_video).setVisibility(View.GONE); + findViewById(R.id.btn_reverse_video).setVisibility(View.GONE); } @Override @@ -131,6 +134,9 @@ public class VideoHandleActivity extends AppCompatActivity implements View.OnCli case R.id.btn_multi_video: handleType = 9; break; + case R.id.btn_reverse_video: + handleType = 10; + break; default: handleType = 0; break; @@ -219,6 +225,11 @@ public class VideoHandleActivity extends AppCompatActivity implements View.OnCli String outputFile = PATH + File.separator + "multi.mp4"; commandLine = FFmpegUtil.multiVideo(input1, input2, outputFile, VideoLayout.LAYOUT_HORIZONTAL); break; + case 10://视频反序倒播 + String input = PATH + File.separator + "beyond.mp4"; + String output = PATH + File.separator + "reverse.mp4"; + commandLine = FFmpegUtil.reverseVideo(input, output); + break; default: break; } diff --git a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java index 3fc2389..8ee3bc2 100644 --- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java +++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java @@ -249,4 +249,19 @@ public class FFmpegUtil { return multiVideo.split(" "); } + /** + * 视频反序倒播 + * @param inputFile 输入文件 + * @param targetFile 反序文件 + * + * @return 视频反序的命令行 + */ + public static String[] reverseVideo(String inputFile, String targetFile){ + //FIXME 音频也反序 +// String reverseVideo = "ffmpeg -i %s -filter_complex [0:v]reverse[v];[0:a]areverse[a] -map [v] -map [a] %s"; + String reverseVideo = "ffmpeg -i %s -filter_complex [0:v]reverse[v] -map [v] %s";//单纯视频反序 + reverseVideo = String.format(reverseVideo, inputFile, targetFile); + return reverseVideo.split(" "); + } + } diff --git a/app/src/main/res/layout/activity_video_handle.xml b/app/src/main/res/layout/activity_video_handle.xml index b8c827b..cefb54d 100644 --- a/app/src/main/res/layout/activity_video_handle.xml +++ b/app/src/main/res/layout/activity_video_handle.xml @@ -10,7 +10,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" - android:layout_marginTop="20dp" + android:layout_marginTop="10dp" android:text="@string/video_transform"/>