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 8007a73..3baa13e 100644
--- a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt
+++ b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt
@@ -123,7 +123,8 @@ class VideoHandleActivity : BaseActivity() {
getString(R.string.video_thumbnail),
getString(R.string.video_subtitle),
getString(R.string.video_rotate),
- getString(R.string.video_gop))
+ getString(R.string.video_gop),
+ getString(R.string.video_gray))
layoutVideoHandle = findViewById(R.id.list_video_item)
val layoutManager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
@@ -316,17 +317,14 @@ class VideoHandleActivity : BaseActivity() {
}
val filePath = FileUtil.getFilePath(srcFile)
var fileName = FileUtil.getFileName(srcFile)
- Log.e(TAG, "moov filePath=$filePath--fileName=$fileName")
fileName = "moov_" + fileName!!
val moovPath = filePath + File.separator + fileName
if (useFFmpegCmd) {
commandLine = FFmpegUtil.moveMoovAhead(srcFile, moovPath)
} else {
- val start = System.currentTimeMillis()
val ffmpegCmd = FFmpegCmd()
val result = ffmpegCmd.moveMoovAhead(srcFile, moovPath)
Log.e(TAG, "result=" + (result == 0))
- Log.e(TAG, "move moov use time=" + (System.currentTimeMillis() - start))
}
}
14 //playing speed of video
@@ -367,6 +365,11 @@ class VideoHandleActivity : BaseActivity() {
val gopPath = PATH + File.separator + "gop" + gop + suffix
commandLine = FFmpegUtil.changeGOP(srcFile, gop, gopPath)
}
+ 20 // change video from RGB to gray
+ -> {
+ val grayPath = PATH + File.separator + "gray" + suffix
+ commandLine = FFmpegUtil.toGrayVideo(srcFile, grayPath)
+ }
else -> {
}
}
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 7347a00..c70f463 100644
--- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
+++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
@@ -612,6 +612,18 @@ public class FFmpegUtil {
return moovCmd.split(" ");
}
+ /**
+ * Change Video from RGB to gray(black & white)
+ * @param inputPath inputPath
+ * @param outputPath outputPath
+ * @return grayCmd
+ */
+ public static String[] toGrayVideo(String inputPath, String outputPath) {
+ String grayCmd = "ffmpeg -i %s -vf lutyuv='u=128:v=128' %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 373b3e0..d0ee7cd 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -67,6 +67,7 @@
Insert thumbnail
add subtitle
KeyFrame interval
+ Gray video
Swap
Start
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f3bce06..8e4789b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -67,6 +67,7 @@
插入封面
添加字幕
关键帧间隔
+ 黑白视频
切换
开始
diff --git a/doc/FFmpeg_command_line.md b/doc/FFmpeg_command_line.md
index 8e5aee2..3b36ffd 100644
--- a/doc/FFmpeg_command_line.md
+++ b/doc/FFmpeg_command_line.md
@@ -183,8 +183,8 @@ ffmpeg -ss 20 -accurate_seek -t 10 -i input.mp4 -an -r 5 %3d.jpg
使用setpts设置视频速度,atempo设置音频速度:
ffmpeg -i in.mp4 -filter_complex [0:v]setpts=%.2f*PTS[v];[0:a]atempo=%.2f[a] -map [v] -map [a] out.mp4
-### 3.12 旋转视频
-ffmpeg -i in.mp4 -c copy -metadata:s\:v:0 rotate=90 out.mp4
+### 3.12 黑白视频
+ffmpeg -i in.mp4 -vf lutyuv='u=128:v=128' out.mp4
# 二、ffplay命令行
ffplay主要用于播放视频,也可以播放网络流,示例如下:
diff --git a/doc/FFmpeg_compile_shell.md b/doc/FFmpeg_compile_shell.md
index d6c6763..3c41c59 100644
--- a/doc/FFmpeg_compile_shell.md
+++ b/doc/FFmpeg_compile_shell.md
@@ -47,7 +47,7 @@ swscale提供图像缩放与像素格式转换,swresample提供音频重采样
| --disable-all | disable components, libs |
| --disable-autodetect | disable detect external libs|
- | Program options: | |
+ | Program options: | Description |
|:------------------------|:----------------------------|
| --disable-programs | don't build command line |
| --disable-ffmpeg | disable ffmpeg build |