Commit 34a7eeb58024377bfcce251d75a149342139b90b

Authored by 648540858
1 parent 753efef3

添加合并文件性能限制

src/main/java/top/panll/assist/dto/UserSettings.java
@@ -21,6 +21,9 @@ public class UserSettings { @@ -21,6 +21,9 @@ public class UserSettings {
21 @Value("${userSettings.ffprobe}") 21 @Value("${userSettings.ffprobe}")
22 private String ffprobe; 22 private String ffprobe;
23 23
  24 + @Value("${userSettings.threads:2}")
  25 + private int threads;
  26 +
24 public String getRecord() { 27 public String getRecord() {
25 return record; 28 return record;
26 } 29 }
@@ -64,4 +67,12 @@ public class UserSettings { @@ -64,4 +67,12 @@ public class UserSettings {
64 public void setRecordTempDay(int recordTempDay) { 67 public void setRecordTempDay(int recordTempDay) {
65 this.recordTempDay = recordTempDay; 68 this.recordTempDay = recordTempDay;
66 } 69 }
  70 +
  71 + public int getThreads() {
  72 + return threads;
  73 + }
  74 +
  75 + public void setThreads(int threads) {
  76 + this.threads = threads;
  77 + }
67 } 78 }
src/main/java/top/panll/assist/service/FFmpegExecUtils.java
@@ -116,6 +116,7 @@ public class FFmpegExecUtils implements InitializingBean{ @@ -116,6 +116,7 @@ public class FFmpegExecUtils implements InitializingBean{
116 .overrideOutputFiles(true) 116 .overrideOutputFiles(true)
117 .setInput(fileListName) // Or filename 117 .setInput(fileListName) // Or filename
118 .addExtraArgs("-safe", "0") 118 .addExtraArgs("-safe", "0")
  119 + .addExtraArgs("-threads", userSettings.getThreads() + "")
119 .addOutput(recordFileResultPath) 120 .addOutput(recordFileResultPath)
120 .setVideoCodec("copy") 121 .setVideoCodec("copy")
121 .setAudioCodec("copy") 122 .setAudioCodec("copy")
src/main/resources/application-dev.yml
@@ -38,6 +38,8 @@ userSettings: @@ -38,6 +38,8 @@ userSettings:
38 ffmpeg: /usr/bin/ffmpeg 38 ffmpeg: /usr/bin/ffmpeg
39 # [必选 ] ffprobe路径, 一般安装ffmpeg就会自带, 一般跟ffmpeg在同一目录,用于查询文件的信息 39 # [必选 ] ffprobe路径, 一般安装ffmpeg就会自带, 一般跟ffmpeg在同一目录,用于查询文件的信息
40 ffprobe: /usr/bin/ffprobe 40 ffprobe: /usr/bin/ffprobe
  41 + # [可选 ] 限制 ffmpeg 合并文件使用的线程数,间接限制cpu使用率, 默认2 限制到50%
  42 + threads: 2
41 43
42 swagger-ui: 44 swagger-ui:
43 enabled: true 45 enabled: true