set the rotate degree of video

dev
xufuji456 3 years ago
parent 9ceed1d4af
commit 0e6e6ccba5
  1. 10
      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

@ -118,7 +118,8 @@ class VideoHandleActivity : BaseActivity() {
R.id.btn_speed, R.id.btn_speed,
R.id.btn_flv, R.id.btn_flv,
R.id.btn_thumbnail, R.id.btn_thumbnail,
R.id.btn_add_subtitle R.id.btn_add_subtitle,
R.id.btn_rotate
) )
} }
@ -328,11 +329,16 @@ class VideoHandleActivity : BaseActivity() {
} }
R.id.btn_add_subtitle//add subtitle into video R.id.btn_add_subtitle//add subtitle into video
-> { -> {
Log.e(TAG, "add subtitle...")
val subtitlePath = PATH + File.separator + "test.ass" val subtitlePath = PATH + File.separator + "test.ass"
val addSubtitlePath = PATH + File.separator + "subtitle" + suffix val addSubtitlePath = PATH + File.separator + "subtitle" + suffix
commandLine = FFmpegUtil.addSubtitleIntoVideo(srcFile, subtitlePath, addSubtitlePath) commandLine = FFmpegUtil.addSubtitleIntoVideo(srcFile, subtitlePath, addSubtitlePath)
} }
R.id.btn_rotate// set the rotate degree of video
-> {
val rotateDegree = 90
val addSubtitlePath = PATH + File.separator + "rotate" + rotateDegree + suffix
commandLine = FFmpegUtil.rotateVideo(srcFile, rotateDegree, addSubtitlePath)
}
else -> { else -> {
} }
} }

@ -693,4 +693,10 @@ public class FFmpegUtil {
return pushStreams.split(" "); return pushStreams.split(" ");
} }
public static String[] rotateVideo(String inputPath, int rotateDegree, String outputPath) {
String rotateCmd = "ffmpeg -i %s -c copy -metadata:s:v:0 rotate=%d %s";
rotateCmd = String.format(Locale.getDefault(), rotateCmd, inputPath, rotateDegree, outputPath);
return rotateCmd.split(" ");
}
} }

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

Loading…
Cancel
Save