|
@@ -55,22 +55,28 @@ public class FfmpegUtil {
|
|
|
|
|
|
public static boolean getTargetTimeThumbnail(String url, String targetPath, String timestamp) {
|
|
|
try {
|
|
|
- try (ProcessWrapper ffmpeg = new DefaultFFMPEGLocator().createExecutor()) {
|
|
|
- ffmpeg.addArgument("-ss");
|
|
|
- ffmpeg.addArgument(timestamp);
|
|
|
- ffmpeg.addArgument("-i");
|
|
|
- ffmpeg.addArgument(url);
|
|
|
- ffmpeg.addArgument("-vframes");
|
|
|
- ffmpeg.addArgument("1");
|
|
|
- ffmpeg.addArgument(targetPath);
|
|
|
- ffmpeg.execute();
|
|
|
- try (BufferedReader br = new BufferedReader(new InputStreamReader(ffmpeg.getErrorStream()))) {
|
|
|
- blockFfmpeg(br);
|
|
|
- }
|
|
|
+
|
|
|
+ DefaultFFMPEGLocator defaultFFMPEGLocator = new DefaultFFMPEGLocator();
|
|
|
+ String executablePath = defaultFFMPEGLocator.getExecutablePath();
|
|
|
+ log.info("executablePath={}", executablePath);
|
|
|
+ ProcessWrapper ffmpeg = defaultFFMPEGLocator.createExecutor();
|
|
|
+
|
|
|
+ ffmpeg.addArgument("-ss");
|
|
|
+ ffmpeg.addArgument(timestamp);
|
|
|
+ ffmpeg.addArgument("-i");
|
|
|
+ ffmpeg.addArgument(url);
|
|
|
+ ffmpeg.addArgument("-vframes");
|
|
|
+ ffmpeg.addArgument("1");
|
|
|
+ ffmpeg.addArgument(targetPath);
|
|
|
+ ffmpeg.execute();
|
|
|
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(ffmpeg.getErrorStream()))) {
|
|
|
+ blockFfmpeg(br);
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
log.error("getTargetTimeThumbnail error", e);
|
|
|
return false;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("getTargetTimeThumbnail error", e);
|
|
|
}
|
|
|
return true;
|
|
|
}
|