diff --git a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java index cbef6b2..0084e74 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.java +++ b/app/src/main/java/com/frank/ffmpeg/activity/VideoHandleActivity.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、图片 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 e2a0031..1cadd86 100644 --- a/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java +++ b/app/src/main/java/com/frank/ffmpeg/util/FFmpegUtil.java @@ -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(" ");//以空格分割为字符串数组 }