增加截图时间参数

增加截图时间参数
pull/107/head
xufulong 5 years ago
parent 79625ea94b
commit 9868188b43
  1. 3
      app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java
  2. 7
      app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java

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

@ -144,13 +144,14 @@ public class FFmpegUtil {
/**
* 使用ffmpeg命令行进行视频截图
* @param srcFile 源文件
* @param time 截图开始时间
* @param size 图片尺寸大小
* @param targetFile 目标文件
* @return 截图后的文件
*/
public static String[] screenShot(String srcFile, String size, String targetFile){
String screenShotCmd = "ffmpeg -i %s -f image2 -t 0.001 -s %s %s";
screenShotCmd = String.format(screenShotCmd, srcFile, size, targetFile);
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);
return screenShotCmd.split(" ");//以空格分割为字符串数组
}

Loading…
Cancel
Save