optimize cmd: screen shot

optimize cmd: screen shot
pull/107/head
xufulong 5 years ago
parent 6b2cbe3ba6
commit ee8eb7654c
  1. 3
      app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java
  2. 7
      app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java

@ -152,9 +152,8 @@ public class VideoHandleActivity extends BaseActivity {
break;
case R.id.btn_screen_shot://视频截图
String screenShot = PATH + File.separator + "screenShot.jpg";
String size = "1080x720";
int time = 18;
commandLine = FFmpegUtil.screenShot(srcFile, time, size, screenShot);
commandLine = FFmpegUtil.screenShot(srcFile, time, screenShot);
break;
case R.id.btn_water_mark://视频添加水印
//1、图片

@ -166,13 +166,12 @@ public class FFmpegUtil {
*
* @param srcFile 源文件
* @param time 截图开始时间
* @param size 图片尺寸大小
* @param targetFile 目标文件
* @return 截图后的文件
*/
public static String[] screenShot(String srcFile, int time, String size, String targetFile) {
String screenShotCmd = "ffmpeg -i %s -f image2 -ss %d -s %s %s";
screenShotCmd = String.format(Locale.getDefault(), screenShotCmd, srcFile, time, size, targetFile);
public static String[] screenShot(String srcFile, int time, String targetFile) {
String screenShotCmd = "ffmpeg -i %s -f image2 -ss %d -vframes 1 -an %s";
screenShotCmd = String.format(Locale.getDefault(), screenShotCmd, srcFile, time, targetFile);
return screenShotCmd.split(" ");
}

Loading…
Cancel
Save