|
@@ -1400,7 +1400,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
}
|
|
|
|
|
|
public void getDuration(String file) {
|
|
|
- String filePath = "/opt/1.m4a";
|
|
|
+ String filePath = "D:\\LY\\1.m4a";
|
|
|
try (FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(filePath)) {
|
|
|
grabber.start();
|
|
|
// 总时长(纳秒)
|
|
@@ -1413,4 +1413,19 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
e.getMessage();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String filePath = "/opt/1.m4a";
|
|
|
+ try (FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(filePath)) {
|
|
|
+ grabber.start();
|
|
|
+ // 总时长(纳秒)
|
|
|
+ long durationInNanoSeconds = grabber.getLengthInTime();
|
|
|
+ // 转换为秒
|
|
|
+ double durationInSeconds = durationInNanoSeconds / 1_000_000.0;
|
|
|
+ log.info("Audio Duration: " + durationInSeconds + " seconds");
|
|
|
+ grabber.stop();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.getMessage();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|