change video from rgb to gray

pull/209/head
xufulong 3 years ago
parent ec020613cc
commit 0e4819068c
  1. 11
      app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.kt
  2. 12
      app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java
  3. 1
      app/src/main/res/values-en/strings.xml
  4. 1
      app/src/main/res/values/strings.xml
  5. 4
      doc/FFmpeg_command_line.md
  6. 2
      doc/FFmpeg_compile_shell.md

@ -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 -> {
}
}

@ -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
*

@ -67,6 +67,7 @@
<string name="video_thumbnail">Insert thumbnail</string>
<string name="video_subtitle">add subtitle</string>
<string name="video_gop">KeyFrame interval</string>
<string name="video_gray">Gray video</string>
<string name="swap">Swap</string>
<string name="start">Start</string>

@ -67,6 +67,7 @@
<string name="video_thumbnail">插入封面</string>
<string name="video_subtitle">添加字幕</string>
<string name="video_gop">关键帧间隔</string>
<string name="video_gray">黑白视频</string>
<string name="swap">切换</string>
<string name="start">开始</string>

@ -183,8 +183,8 @@ ffmpeg -ss 20 -accurate_seek -t 10 -i input.mp4 -an -r 5 %3d.jpg<br>
使用setpts设置视频速度,atempo设置音频速度:<br>
ffmpeg -i in.mp4 -filter_complex [0:v]setpts=%.2f*PTS[v];[0:a]atempo=%.2f[a] -map [v] -map [a] out.mp4<br>
### 3.12 旋转视频
ffmpeg -i in.mp4 -c copy -metadata:s\:v:0 rotate=90 out.mp4<br>
### 3.12 黑白视频
ffmpeg -i in.mp4 -vf lutyuv='u=128:v=128' out.mp4
# 二、ffplay命令行
ffplay主要用于播放视频,也可以播放网络流,示例如下:<br>

@ -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 |

Loading…
Cancel
Save