buld keyframe index of flv

buld keyframe index of flv
pull/166/head
xufulong 4 years ago
parent c34dac76fe
commit b91a61f0ea
  1. 11
      app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java
  2. 12
      app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
  3. 7
      app/src/main/res/layout/activity_video_handle.xml
  4. 1
      app/src/main/res/values-en/strings.xml
  5. 1
      app/src/main/res/values/strings.xml

@ -128,7 +128,8 @@ public class VideoHandleActivity extends BaseActivity {
R.id.btn_to_image, R.id.btn_to_image,
R.id.btn_pip, R.id.btn_pip,
R.id.btn_moov, 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"; String speed = PATH + File.separator + "speed.mp4";
commandLine = FFmpegUtil.changeSpeed(srcFile, speed, 2f, false); commandLine = FFmpegUtil.changeSpeed(srcFile, speed, 2f, false);
break; 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: default:
break; break;
} }

@ -520,4 +520,16 @@ public class FFmpegUtil {
return speedCmd.split(" "); 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(" ");
}
} }

@ -128,6 +128,13 @@
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:text="@string/video_speed"/> android:text="@string/video_speed"/>
<Button
android:id="@+id/btn_flv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/video_flv"/>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

@ -43,6 +43,7 @@
<string name="video_preview">Video preview</string> <string name="video_preview">Video preview</string>
<string name="video_moov">MOOV move ahead</string> <string name="video_moov">MOOV move ahead</string>
<string name="video_speed">Playing speed</string> <string name="video_speed">Playing speed</string>
<string name="video_flv">FLV index</string>
<string name="swap">Swap</string> <string name="swap">Swap</string>
<string name="start">Start</string> <string name="start">Start</string>

@ -43,6 +43,7 @@
<string name="video_preview">播放预览</string> <string name="video_preview">播放预览</string>
<string name="video_moov">MOOV前移</string> <string name="video_moov">MOOV前移</string>
<string name="video_speed">播放倍率</string> <string name="video_speed">播放倍率</string>
<string name="video_flv">FLV索引</string>
<string name="swap">切换</string> <string name="swap">切换</string>
<string name="start">开始</string> <string name="start">开始</string>

Loading…
Cancel
Save