Change gop(key frame interval) of video

dev
xufuji456 3 years ago
parent d754d44275
commit c9c3529f2f
  1. 9
      app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt
  2. 6
      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. 3
      app/src/main/res/values/strings.xml

@ -119,7 +119,8 @@ class VideoHandleActivity : BaseActivity() {
R.id.btn_flv,
R.id.btn_thumbnail,
R.id.btn_add_subtitle,
R.id.btn_rotate
R.id.btn_rotate,
R.id.btn_gop
)
}
@ -339,6 +340,12 @@ class VideoHandleActivity : BaseActivity() {
val addSubtitlePath = PATH + File.separator + "rotate" + rotateDegree + suffix
commandLine = FFmpegUtil.rotateVideo(srcFile, rotateDegree, addSubtitlePath)
}
R.id.btn_gop// change the gop(key frame interval) of video
-> {
val gop = 30
val gopPath = PATH + File.separator + "gop" + gop + suffix
commandLine = FFmpegUtil.changeGOP(srcFile, gop, gopPath)
}
else -> {
}
}

@ -699,4 +699,10 @@ public class FFmpegUtil {
return rotateCmd.split(" ");
}
public static String[] changeGOP(String inputPath, int gop, String outputPath) {
String rotateCmd = "ffmpeg -i %s -g %d %s";
rotateCmd = String.format(Locale.getDefault(), rotateCmd, inputPath, gop, outputPath);
return rotateCmd.split(" ");
}
}

@ -156,6 +156,13 @@
android:layout_marginTop="4dp"
android:text="@string/video_rotate"/>
<Button
android:id="@+id/btn_gop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/video_gop"/>
</LinearLayout>
</ScrollView>

@ -60,6 +60,7 @@
<string name="video_flv">FLV index</string>
<string name="video_thumbnail">Insert thumbnail</string>
<string name="video_subtitle">add subtitle</string>
<string name="video_gop">KeyFrame interval</string>
<string name="swap">Swap</string>
<string name="start">Start</string>

@ -42,7 +42,7 @@
<string name="video_transform">视频转码</string>
<string name="video_screen_shot">视频截图</string>
<string name="video_screen_record">屏幕录制</string>
<string name="video_from_photo">图片合成视频</string>
<string name="video_from_photo">合成视频</string>
<string name="video_extract_frame">视频抽帧</string>
<string name="video_part_zoom">视频局部放大</string>
<string name="video_play">视频播放</string>
@ -60,6 +60,7 @@
<string name="video_flv">FLV索引</string>
<string name="video_thumbnail">插入封面</string>
<string name="video_subtitle">添加字幕</string>
<string name="video_gop">关键帧间隔</string>
<string name="swap">切换</string>
<string name="start">开始</string>

Loading…
Cancel
Save