diff --git a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt
index e74d9b2..4dce853 100644
--- a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt
+++ b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt
@@ -121,13 +121,12 @@ class VideoHandleActivity : BaseActivity() {
getString(R.string.video_denoise),
getString(R.string.video_image),
getString(R.string.video_pip),
- getString(R.string.video_moov),
getString(R.string.video_speed),
getString(R.string.video_thumbnail),
getString(R.string.video_subtitle),
getString(R.string.video_rotate),
- getString(R.string.video_gop),
- getString(R.string.video_gray))
+ getString(R.string.video_gray),
+ getString(R.string.video_zoom))
layoutVideoHandle = findViewById(R.id.list_video_item)
val layoutManager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
@@ -165,10 +164,10 @@ class VideoHandleActivity : BaseActivity() {
if (!FileUtil.checkFileExist(srcFile)) {
return
}
- if (!FileUtil.isVideo(srcFile)) {
- showToast(getString(R.string.wrong_video_format))
- return
- }
+// if (!FileUtil.isVideo(srcFile)) {
+// showToast(getString(R.string.wrong_video_format))
+// return
+// }
val suffix = FileUtil.getFileSuffix(srcFile)
if (suffix == null || suffix.isEmpty()) {
return
@@ -311,58 +310,39 @@ class VideoHandleActivity : BaseActivity() {
outputPath = PATH + File.separator + "PicInPic.mp4"
commandLine = FFmpegUtil.picInPicVideo(inputFile1, inputFile2, x, y, outputPath)
}
- 13 //moov box moves ahead, which is behind mdat box of mp4 video
- -> {
- if (!srcFile.endsWith(FileUtil.TYPE_MP4)) {
- showToast(getString(R.string.tip_not_mp4_video))
- return
- }
- val filePath = FileUtil.getFilePath(srcFile)
- var fileName = FileUtil.getFileName(srcFile)
- fileName = "moov_" + fileName!!
- outputPath = filePath + File.separator + fileName
- if (useFFmpegCmd) {
- commandLine = FFmpegUtil.moveMoovAhead(srcFile, outputPath)
- } else {
- val ffmpegCmd = FFmpegCmd()
- val result = ffmpegCmd.moveMoovAhead(srcFile, outputPath)
- Log.e(TAG, "result=" + (result == 0))
- }
- }
- 14 //playing speed of video
+ 13 //playing speed of video
-> {
outputPath = PATH + File.separator + "speed.mp4"
commandLine = FFmpegUtil.changeSpeed(srcFile, outputPath, 2f, false)
}
- 15 // insert thumbnail into video
+ 14 // insert thumbnail into video
-> {
val thumbnailPath = PATH + File.separator + "thumb.jpg"
outputPath = PATH + File.separator + "thumbnailVideo" + suffix
commandLine = FFmpegUtil.insertPicIntoVideo(srcFile, thumbnailPath, outputPath)
}
- 16 //add subtitle into video
+ 15 //add subtitle into video
-> {
val subtitlePath = PATH + File.separator + "test.ass"
outputPath = PATH + File.separator + "subtitle.mkv"
commandLine = FFmpegUtil.addSubtitleIntoVideo(srcFile, subtitlePath, outputPath)
}
- 17 // set the rotate degree of video
+ 16 // set the rotate degree of video
-> {
val rotateDegree = 90
outputPath = PATH + File.separator + "rotate" + rotateDegree + suffix
commandLine = FFmpegUtil.rotateVideo(srcFile, rotateDegree, outputPath)
}
- 18 // change the gop(key frame interval) of video
- -> {
- val gop = 30
- outputPath = PATH + File.separator + "gop" + gop + suffix
- commandLine = FFmpegUtil.changeGOP(srcFile, gop, outputPath)
- }
- 19 // change video from RGB to gray
+ 17 // change video from RGB to gray
-> {
outputPath = PATH + File.separator + "gray" + suffix
commandLine = FFmpegUtil.toGrayVideo(srcFile, outputPath)
}
+ 18 // zoom photo to video
+ -> {
+ outputPath = PATH + File.separator + "zoom.mp4"
+ commandLine = FFmpegUtil.photoZoomToVideo(srcFile, outputPath)
+ }
else -> {
}
}
@@ -406,6 +386,25 @@ class VideoHandleActivity : BaseActivity() {
ffmpegHandler!!.executeFFmpegCmds(commandList)
}
+ private fun moov(srcFile: String) {
+ if (!srcFile.endsWith(FileUtil.TYPE_MP4)) {
+ showToast(getString(R.string.tip_not_mp4_video))
+ return
+ }
+ val filePath = FileUtil.getFilePath(srcFile)
+ var fileName = FileUtil.getFileName(srcFile)
+ fileName = "moov_" + fileName!!
+ outputPath = filePath + File.separator + fileName
+ if (useFFmpegCmd) {
+ val commandLine = FFmpegUtil.moveMoovAhead(srcFile, outputPath)
+ ffmpegHandler!!.executeFFmpegCmd(commandLine)
+ } else {
+ val ffmpegCmd = FFmpegCmd()
+ val result = ffmpegCmd.moveMoovAhead(srcFile, outputPath)
+ Log.e(TAG, "result=" + (result == 0))
+ }
+ }
+
/**
* Combine pictures into video
*/
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 0f66bff..43fbe6a 100644
--- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
+++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
@@ -624,6 +624,18 @@ public class FFmpegUtil {
return grayCmd.split(" ");
}
+ /**
+ * Photo zoom to video
+ * @param inputPath inputPath
+ * @param outputPath outputPath
+ * @return zoomCmd
+ */
+ public static String[] photoZoomToVideo(String inputPath, String outputPath) {
+ String grayCmd = "ffmpeg -loop 1 -i %s -vf zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=125 -t 8 %s";
+ grayCmd = String.format(Locale.getDefault(), grayCmd, inputPath, outputPath);
+ return grayCmd.split(" ");
+ }
+
/**
* using FFprobe to parse the media format
*
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index fcb9165..566ef6d 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -65,7 +65,7 @@
Playing speed
Insert thumbnail
add subtitle
- KeyFrame interval
+ Zoom video
Gray video
Swap
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cc18dc3..09680fb 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -65,7 +65,7 @@
播放倍率
插入封面
添加字幕
- 关键帧间隔
+ 图片缩放
黑白视频
切换