|
@@ -1,7 +1,7 @@
|
|
-package com.iden.common.util;
|
|
|
|
|
|
+package com.face.video;
|
|
|
|
|
|
|
|
|
|
-import com.iden.common.enums.TimeoutOption;
|
|
|
|
|
|
+import com.iden.common.util.DateUtils;
|
|
import net.bramp.ffmpeg.FFmpeg;
|
|
import net.bramp.ffmpeg.FFmpeg;
|
|
import net.bramp.ffmpeg.FFmpegExecutor;
|
|
import net.bramp.ffmpeg.FFmpegExecutor;
|
|
import net.bramp.ffmpeg.FFprobe;
|
|
import net.bramp.ffmpeg.FFprobe;
|
|
@@ -17,8 +17,10 @@ import javax.swing.*;
|
|
import java.awt.*;
|
|
import java.awt.*;
|
|
import java.awt.image.BufferedImage;
|
|
import java.awt.image.BufferedImage;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
-import java.util.*;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -26,11 +28,11 @@ import java.util.List;
|
|
*
|
|
*
|
|
* @author
|
|
* @author
|
|
*/
|
|
*/
|
|
-public class VideoUtil {
|
|
|
|
|
|
+public class VideoTest {
|
|
|
|
|
|
private static final int SECOND = 50;
|
|
private static final int SECOND = 50;
|
|
|
|
|
|
- private static final Logger logger = LoggerFactory.getLogger(VideoUtil.class);
|
|
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(VideoTest.class);
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取指定视频的帧并保存为图片至指定目录
|
|
* 获取指定视频的帧并保存为图片至指定目录
|
|
@@ -41,7 +43,7 @@ public class VideoUtil {
|
|
*/
|
|
*/
|
|
public static List<File> fetchPic(File videoFile, String saveFile, int second) throws Exception {
|
|
public static List<File> fetchPic(File videoFile, String saveFile, int second) throws Exception {
|
|
|
|
|
|
- java.util.List<File> files = new ArrayList<>();
|
|
|
|
|
|
+ List<File> files = new ArrayList<>();
|
|
|
|
|
|
FFmpegFrameGrabber ff = new FFmpegFrameGrabber(videoFile);
|
|
FFmpegFrameGrabber ff = new FFmpegFrameGrabber(videoFile);
|
|
ff.start();
|
|
ff.start();
|
|
@@ -86,7 +88,7 @@ public class VideoUtil {
|
|
|
|
|
|
public static List<File> fetchPicByCount(File videoFile, String saveDir, int count) throws Exception {
|
|
public static List<File> fetchPicByCount(File videoFile, String saveDir, int count) throws Exception {
|
|
|
|
|
|
- java.util.List<File> files = new ArrayList<>();
|
|
|
|
|
|
+ List<File> files = new ArrayList<>();
|
|
|
|
|
|
FFmpegFrameGrabber ff = new FFmpegFrameGrabber(videoFile);
|
|
FFmpegFrameGrabber ff = new FFmpegFrameGrabber(videoFile);
|
|
ff.start();
|
|
ff.start();
|
|
@@ -125,7 +127,7 @@ public class VideoUtil {
|
|
|
|
|
|
Long endTime = shootEndTime.getTime() ;
|
|
Long endTime = shootEndTime.getTime() ;
|
|
|
|
|
|
- java.util.List<File> files = new ArrayList<>();
|
|
|
|
|
|
+ List<File> files = new ArrayList<>();
|
|
|
|
|
|
FFmpegFrameGrabber ff = new FFmpegFrameGrabber(videoFile);
|
|
FFmpegFrameGrabber ff = new FFmpegFrameGrabber(videoFile);
|
|
ff.start();
|
|
ff.start();
|
|
@@ -296,16 +298,16 @@ public class VideoUtil {
|
|
grabber.release();
|
|
grabber.release();
|
|
}
|
|
}
|
|
|
|
|
|
- public void cut3() throws Exception{
|
|
|
|
- FFmpeg ffmpeg = new FFmpeg("/path/to/ffmpeg");
|
|
|
|
- FFprobe ffprobe = new FFprobe("/path/to/ffprobe");
|
|
|
|
|
|
+ public static void cut3() throws Exception{
|
|
|
|
+ FFmpeg ffmpeg = new FFmpeg("C:\\Users\\STW\\Downloads\\ffmpeg-3.1.3\\ffmpeg-3.1.3\\ffmpeg");
|
|
|
|
+ FFprobe ffprobe = new FFprobe("C:\\Users\\STW\\Downloads\\ffmpeg-3.1.3\\ffmpeg-3.1.3\\ffprobe");
|
|
|
|
|
|
FFmpegBuilder builder = new FFmpegBuilder()
|
|
FFmpegBuilder builder = new FFmpegBuilder()
|
|
|
|
|
|
- .setInput("input.mp4") // Filename, or a FFmpegProbeResult
|
|
|
|
|
|
+ .setInput("e:/20211223123223_76639ced-6400-11ec-b8f9-fa163e4e1e9f.mp4") // Filename, or a FFmpegProbeResult
|
|
.overrideOutputFiles(true) // Override the output if it exists
|
|
.overrideOutputFiles(true) // Override the output if it exists
|
|
|
|
|
|
- .addOutput("output.mp4") // Filename for the destination
|
|
|
|
|
|
+ .addOutput("e:/output.mp4") // Filename for the destination
|
|
.setFormat("mp4") // Format is inferred from filename, or can be set
|
|
.setFormat("mp4") // Format is inferred from filename, or can be set
|
|
.setTargetSize(250_000) // Aim for a 250KB file
|
|
.setTargetSize(250_000) // Aim for a 250KB file
|
|
|
|
|
|
@@ -340,9 +342,10 @@ public class VideoUtil {
|
|
// System.out.println(files.get(0).getName());
|
|
// System.out.println(files.get(0).getName());
|
|
// System.out.println(VideoUtil.getVideoTime(file));
|
|
// System.out.println(VideoUtil.getVideoTime(file));
|
|
|
|
|
|
- Date shootEndTime = DateUtils.strToDate("20211223123223","yyyyMMddHHmmss");
|
|
|
|
|
|
+ // Date shootEndTime = DateUtils.strToDate("20211223123223","yyyyMMddHHmmss");
|
|
// fetchAllPic(file,"E:/223",shootEndTime);
|
|
// fetchAllPic(file,"E:/223",shootEndTime);
|
|
// cut3(file,new File("e:/a.mp4"));
|
|
// cut3(file,new File("e:/a.mp4"));
|
|
|
|
+ cut3();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|