GUI-STUDIO commited on
Commit ·
ea29673
1
Parent(s): 93cd31e
changes
Browse files- src/lib/ffmpeg.ts +12 -11
- src/sub-router/showtime.ts +1 -1
src/lib/ffmpeg.ts
CHANGED
|
@@ -1047,7 +1047,7 @@ async function F_build_ffmpeg_command_v3(arg0: {
|
|
| 1047 |
// -------------------------------
|
| 1048 |
// ADD THREAD LIMIT (Crucial for 0.25 vCPU)
|
| 1049 |
// -------------------------------
|
| 1050 |
-
if (!CPU_0V1 || `${CPU_0V1}` !== "1") command.push("-threads", "1");
|
| 1051 |
|
| 1052 |
// -------------------------------
|
| 1053 |
// Network reconnect options (network resilience)
|
|
@@ -1059,9 +1059,10 @@ async function F_build_ffmpeg_command_v3(arg0: {
|
|
| 1059 |
command.push("-reconnect_streamed", "1");
|
| 1060 |
command.push("-reconnect_delay_max", "30");
|
| 1061 |
command.push("-reconnect_on_network_error", "1");
|
| 1062 |
-
command.push("-reconnect_on_http_error", "429,502,503,504");
|
| 1063 |
|
| 1064 |
-
command.push("-rw_timeout", timeoutVal, "-timeout", timeoutVal);
|
|
|
|
| 1065 |
|
| 1066 |
if (has_tcp_progress) {
|
| 1067 |
command.push("-multiple_requests", "1");
|
|
@@ -1239,7 +1240,7 @@ async function F_build_ffmpeg_command_v3(arg0: {
|
|
| 1239 |
Array.isArray(valid_bun_subs) &&
|
| 1240 |
valid_bun_subs.length > 0;
|
| 1241 |
|
| 1242 |
-
const
|
| 1243 |
valid_bun_subs?.length ||
|
| 1244 |
probe_data.videoCodec !== "h264" ||
|
| 1245 |
probe_data.audioCodec !== "aac" ||
|
|
@@ -1253,7 +1254,7 @@ async function F_build_ffmpeg_command_v3(arg0: {
|
|
| 1253 |
command.push("-map", "0:v:0?");
|
| 1254 |
}
|
| 1255 |
|
| 1256 |
-
if (
|
| 1257 |
command.push("-c:v", hw_encoder || "libx264");
|
| 1258 |
|
| 1259 |
if (is_burning && valid_bun_subs[0].path) {
|
|
@@ -1273,9 +1274,9 @@ async function F_build_ffmpeg_command_v3(arg0: {
|
|
| 1273 |
command.push("-map", "0:a:0");
|
| 1274 |
}
|
| 1275 |
|
| 1276 |
-
if (
|
| 1277 |
command.push("-c:a", "aac", "-b:a", "256k");
|
| 1278 |
-
command.push("-async", "1");
|
| 1279 |
command.push("-af", "loudnorm=I=-14:TP=-1.5:LRA=11,aresample=async=1");
|
| 1280 |
} else {
|
| 1281 |
command.push("-c:a", "copy", "-bsf:a", "aac_adtstoasc");
|
|
@@ -1344,9 +1345,9 @@ async function F_build_ffmpeg_command_v3(arg0: {
|
|
| 1344 |
if(live === "stream") {
|
| 1345 |
command.push("-tune", "zerolatency");
|
| 1346 |
}
|
| 1347 |
-
command.push("-crf", "23");
|
| 1348 |
-
command.push("-preset", use_ultrafast ? "ultrafast" : "medium"); // ultrafast veryfast faster medium
|
| 1349 |
-
command.push("-pix_fmt", "yuv420p");
|
| 1350 |
command.push("-max_interleave_delta", "0");
|
| 1351 |
|
| 1352 |
/* OUTPUT FORMAT & FLAGS */
|
|
@@ -1364,7 +1365,7 @@ async function F_build_ffmpeg_command_v3(arg0: {
|
|
| 1364 |
}
|
| 1365 |
|
| 1366 |
if(file_mode) {
|
| 1367 |
-
command.push("-fps_mode", "cfr");
|
| 1368 |
command.push("-max_muxing_queue_size", "9999");
|
| 1369 |
} else {
|
| 1370 |
command.push("-fps_mode", "passthrough");
|
|
|
|
| 1047 |
// -------------------------------
|
| 1048 |
// ADD THREAD LIMIT (Crucial for 0.25 vCPU)
|
| 1049 |
// -------------------------------
|
| 1050 |
+
// if (!CPU_0V1 || `${CPU_0V1}` !== "1") command.push("-threads", "1");
|
| 1051 |
|
| 1052 |
// -------------------------------
|
| 1053 |
// Network reconnect options (network resilience)
|
|
|
|
| 1059 |
command.push("-reconnect_streamed", "1");
|
| 1060 |
command.push("-reconnect_delay_max", "30");
|
| 1061 |
command.push("-reconnect_on_network_error", "1");
|
| 1062 |
+
command.push("-reconnect_on_http_error", "429,500,502,503,504");
|
| 1063 |
|
| 1064 |
+
// command.push("-rw_timeout", timeoutVal, "-timeout", timeoutVal);
|
| 1065 |
+
command.push("-rw_timeout", timeoutVal);
|
| 1066 |
|
| 1067 |
if (has_tcp_progress) {
|
| 1068 |
command.push("-multiple_requests", "1");
|
|
|
|
| 1240 |
Array.isArray(valid_bun_subs) &&
|
| 1241 |
valid_bun_subs.length > 0;
|
| 1242 |
|
| 1243 |
+
const must_re_encode =
|
| 1244 |
valid_bun_subs?.length ||
|
| 1245 |
probe_data.videoCodec !== "h264" ||
|
| 1246 |
probe_data.audioCodec !== "aac" ||
|
|
|
|
| 1254 |
command.push("-map", "0:v:0?");
|
| 1255 |
}
|
| 1256 |
|
| 1257 |
+
if (must_re_encode) {
|
| 1258 |
command.push("-c:v", hw_encoder || "libx264");
|
| 1259 |
|
| 1260 |
if (is_burning && valid_bun_subs[0].path) {
|
|
|
|
| 1274 |
command.push("-map", "0:a:0");
|
| 1275 |
}
|
| 1276 |
|
| 1277 |
+
if (must_re_encode || re_encode_audio) {
|
| 1278 |
command.push("-c:a", "aac", "-b:a", "256k");
|
| 1279 |
+
// command.push("-async", "1");
|
| 1280 |
command.push("-af", "loudnorm=I=-14:TP=-1.5:LRA=11,aresample=async=1");
|
| 1281 |
} else {
|
| 1282 |
command.push("-c:a", "copy", "-bsf:a", "aac_adtstoasc");
|
|
|
|
| 1345 |
if(live === "stream") {
|
| 1346 |
command.push("-tune", "zerolatency");
|
| 1347 |
}
|
| 1348 |
+
if(must_re_encode) command.push("-crf", "23");
|
| 1349 |
+
if(must_re_encode) command.push("-preset", use_ultrafast ? "ultrafast" : "medium"); // ultrafast veryfast faster medium
|
| 1350 |
+
if(must_re_encode) command.push("-pix_fmt", "yuv420p");
|
| 1351 |
command.push("-max_interleave_delta", "0");
|
| 1352 |
|
| 1353 |
/* OUTPUT FORMAT & FLAGS */
|
|
|
|
| 1365 |
}
|
| 1366 |
|
| 1367 |
if(file_mode) {
|
| 1368 |
+
// command.push("-fps_mode", "cfr"); // passthrough cfr
|
| 1369 |
command.push("-max_muxing_queue_size", "9999");
|
| 1370 |
} else {
|
| 1371 |
command.push("-fps_mode", "passthrough");
|
src/sub-router/showtime.ts
CHANGED
|
@@ -1319,7 +1319,7 @@ async function F_handle_process(arg0: {
|
|
| 1319 |
// -------------------------------
|
| 1320 |
// spawn
|
| 1321 |
// -------------------------------
|
| 1322 |
-
console.log("[FFMPEG CMD]", commands, "\n");
|
| 1323 |
|
| 1324 |
const bun_proc = (() => {
|
| 1325 |
let proc: Subprocess<"ignore" | "pipe", "pipe", "pipe">;
|
|
|
|
| 1319 |
// -------------------------------
|
| 1320 |
// spawn
|
| 1321 |
// -------------------------------
|
| 1322 |
+
console.log("[FFMPEG CMD]", JSON.stringify(commands), "\n");
|
| 1323 |
|
| 1324 |
const bun_proc = (() => {
|
| 1325 |
let proc: Subprocess<"ignore" | "pipe", "pipe", "pipe">;
|