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 0911e46..cf714ad 100644
--- a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java
+++ b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java
@@ -128,7 +128,8 @@ public class VideoHandleActivity extends BaseActivity {
R.id.btn_to_image,
R.id.btn_pip,
R.id.btn_moov,
- R.id.btn_speed
+ R.id.btn_speed,
+ R.id.btn_flv
);
}
@@ -310,6 +311,14 @@ public class VideoHandleActivity extends BaseActivity {
String speed = PATH + File.separator + "speed.mp4";
commandLine = FFmpegUtil.changeSpeed(srcFile, speed, 2f, false);
break;
+ case R.id.btn_flv://rebuild the keyframe index of flv
+ if (!".flv".equalsIgnoreCase(FileUtil.getFileSuffix(srcFile))) {
+ Log.e(TAG, "It's not flv file, suffix=" + FileUtil.getFileSuffix(srcFile));
+ return;
+ }
+ String outputPath = PATH + File.separator + "frame_index.flv";
+ commandLine = FFmpegUtil.buildFlvIndex(srcFile, outputPath);
+ 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 46dd2e1..57d9507 100644
--- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
+++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
@@ -520,4 +520,16 @@ public class FFmpegUtil {
return speedCmd.split(" ");
}
+ /**
+ * Rebuild the keyframe index of FLV, make it seekable
+ * @param inputFile inputFile
+ * @param targetFile targetFile
+ * @return command of build flv index
+ */
+ public static String[] buildFlvIndex(String inputFile, String targetFile) {
+ String denoiseVideo = "ffmpeg -i %s -flvflags add_keyframe_index %s";
+ denoiseVideo = String.format(denoiseVideo, inputFile, targetFile);
+ return denoiseVideo.split(" ");
+ }
+
}
diff --git a/app/src/main/res/layout/activity_video_handle.xml b/app/src/main/res/layout/activity_video_handle.xml
index 752d80d..6e4ebe3 100644
--- a/app/src/main/res/layout/activity_video_handle.xml
+++ b/app/src/main/res/layout/activity_video_handle.xml
@@ -128,6 +128,13 @@
android:layout_marginTop="4dp"
android:text="@string/video_speed"/>
+
+
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index 5a19e6b..abd0663 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -43,6 +43,7 @@
Video preview
MOOV move ahead
Playing speed
+ FLV index
Swap
Start
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2bda7e7..aff0ab2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -43,6 +43,7 @@
播放预览
MOOV前移
播放倍率
+ FLV索引
切换
开始