GUI-STUDIO commited on
Commit
ef76bcd
·
1 Parent(s): c4c1b19
src/lib/ffmpeg.ts CHANGED
@@ -20,8 +20,8 @@ const is_prod =
20
  APP_ENV === "prod" ||
21
  APP_ENV === "pre_prod";
22
 
23
- const ffmpeg_path = is_prod ? "ffmpeg" : ffmpeg || "";
24
- const ffprobe_path = is_prod ? "ffprobe" : ffprobe.path;
25
 
26
  // const ffmpeg_path = ffmpeg || "";
27
  // const ffprobe_path = ffprobe.path;
@@ -221,6 +221,7 @@ async function F_probe_v1(arg0: {
221
  async function F_probe_v2(arg0: {
222
  playback_headers?: Record<string, any> | null;
223
  playback_url: URL;
 
224
  context?: Context;
225
  }) {
226
  const { playback_url, context } = arg0;
@@ -991,7 +992,7 @@ async function F_build_ffmpeg_command_v2(arg0: {
991
  async function F_build_ffmpeg_command_v3(arg0: {
992
  playback_headers?: Record<string, any>;
993
  playback_url: URL;
994
- plackback_type?: string;
995
  context?: Context;
996
  is_net_src?: boolean;
997
  has_tcp_progress?: boolean;
@@ -1008,7 +1009,7 @@ async function F_build_ffmpeg_command_v3(arg0: {
1008
  subtitles,
1009
  probe_data,
1010
  output_format,
1011
- live, plackback_type
1012
  } = arg0;
1013
 
1014
  let { playback_headers } = arg0;
@@ -1031,7 +1032,7 @@ async function F_build_ffmpeg_command_v3(arg0: {
1031
  if (is_net_src) {
1032
  command.push("-reconnect", "1");
1033
  command.push("-reconnect_streamed", "1");
1034
- command.push("-reconnect_delay_max", "15");
1035
 
1036
  command.push("-rw_timeout", timeoutVal, "-timeout", timeoutVal);
1037
 
@@ -1100,13 +1101,14 @@ async function F_build_ffmpeg_command_v3(arg0: {
1100
  // command.push("-http_multiple", "0");
1101
  // command.push("-analyzeduration", "10M");
1102
  // command.push("-probesize", "10M");
1103
- // command.push("-err_detect", "ignore_err");
1104
- // command.push("-fflags", "+discardcorrupt+genpts+nobuffer");
1105
  // command.push("-seg_max_retry", "5");
1106
  // command.push("-max_reload", "100");
1107
 
1108
- if(plackback_type === 'hls') {
1109
- command.push("-http_persistent", "0");
 
 
 
1110
  }
1111
 
1112
  command.push("-i", playback_url.href);
@@ -1339,7 +1341,7 @@ async function F_build_ffmpeg_command_v3(arg0: {
1339
  /* ENCODING & TUNING */
1340
  command.push("-tune", "zerolatency");
1341
  command.push("-crf", "23");
1342
- command.push("-preset", use_ultrafast ? "ultrafast" : "ultrafast"); // veryfast faster medium
1343
  command.push("-pix_fmt", "yuv420p");
1344
  command.push("-max_interleave_delta", "0");
1345
 
@@ -1353,9 +1355,7 @@ async function F_build_ffmpeg_command_v3(arg0: {
1353
 
1354
  command.push(
1355
  "-avoid_negative_ts",
1356
- "make_zero",
1357
- "-fflags",
1358
- "+genpts+nobuffer"
1359
  );
1360
 
1361
  if (live === "stream") {
 
20
  APP_ENV === "prod" ||
21
  APP_ENV === "pre_prod";
22
 
23
+ const ffmpeg_path = !is_prod ? "ffmpeg" : (ffmpeg || "ffmpeg");
24
+ const ffprobe_path = !is_prod ? "ffprobe" : (ffprobe.path || "ffprobe");
25
 
26
  // const ffmpeg_path = ffmpeg || "";
27
  // const ffprobe_path = ffprobe.path;
 
221
  async function F_probe_v2(arg0: {
222
  playback_headers?: Record<string, any> | null;
223
  playback_url: URL;
224
+ playback_type?: string;
225
  context?: Context;
226
  }) {
227
  const { playback_url, context } = arg0;
 
992
  async function F_build_ffmpeg_command_v3(arg0: {
993
  playback_headers?: Record<string, any>;
994
  playback_url: URL;
995
+ playback_type?: string;
996
  context?: Context;
997
  is_net_src?: boolean;
998
  has_tcp_progress?: boolean;
 
1009
  subtitles,
1010
  probe_data,
1011
  output_format,
1012
+ live, playback_type
1013
  } = arg0;
1014
 
1015
  let { playback_headers } = arg0;
 
1032
  if (is_net_src) {
1033
  command.push("-reconnect", "1");
1034
  command.push("-reconnect_streamed", "1");
1035
+ command.push("-reconnect_delay_max", "10");
1036
 
1037
  command.push("-rw_timeout", timeoutVal, "-timeout", timeoutVal);
1038
 
 
1101
  // command.push("-http_multiple", "0");
1102
  // command.push("-analyzeduration", "10M");
1103
  // command.push("-probesize", "10M");
 
 
1104
  // command.push("-seg_max_retry", "5");
1105
  // command.push("-max_reload", "100");
1106
 
1107
+ command.push("-fflags", "+discardcorrupt+genpts+nobuffer");
1108
+ command.push("-err_detect", "ignore_err");
1109
+
1110
+ if(playback_type === 'hls') {
1111
+ command.push("-http_persistent", "1");
1112
  }
1113
 
1114
  command.push("-i", playback_url.href);
 
1341
  /* ENCODING & TUNING */
1342
  command.push("-tune", "zerolatency");
1343
  command.push("-crf", "23");
1344
+ command.push("-preset", use_ultrafast ? "ultrafast" : "medium"); // ultrafast veryfast faster medium
1345
  command.push("-pix_fmt", "yuv420p");
1346
  command.push("-max_interleave_delta", "0");
1347
 
 
1355
 
1356
  command.push(
1357
  "-avoid_negative_ts",
1358
+ "make_zero"
 
 
1359
  );
1360
 
1361
  if (live === "stream") {
src/sub-router/ffmpeg.ts CHANGED
@@ -21,6 +21,7 @@ const sub_router = new Elysia({ prefix: "/ffmpeg" })
21
  let playback = body?.playback;
22
  let playback_headers = body?.playback_headers;
23
  let gen = body?.gen;
 
24
 
25
  const REQ0 = request.url;
26
  const REQ_ORIGIN = (ctx as any).publicOrigin || new URL(REQ0).origin;
@@ -66,7 +67,7 @@ const sub_router = new Elysia({ prefix: "/ffmpeg" })
66
  promise: NS_ffmpeg.F_probe_v2({
67
  playback_url: new URL(playback),
68
  context: ctx,
69
- playback_headers
70
  })
71
  });
72
 
@@ -181,7 +182,7 @@ const sub_router = new Elysia({ prefix: "/ffmpeg" })
181
  subtitles: subtitles_ary,
182
  out_mime,
183
  probe_data,
184
- progress_update_endpoint
185
  };
186
 
187
  const data_str = devalue.stringify(data);
@@ -232,6 +233,14 @@ const sub_router = new Elysia({ prefix: "/ffmpeg" })
232
  error: () => "Invalid playback headers"
233
  })
234
  ),
 
 
 
 
 
 
 
 
235
  gen: t.Optional(
236
  t.Object(
237
  {
 
21
  let playback = body?.playback;
22
  let playback_headers = body?.playback_headers;
23
  let gen = body?.gen;
24
+ let playback_type = body?.playback_type;
25
 
26
  const REQ0 = request.url;
27
  const REQ_ORIGIN = (ctx as any).publicOrigin || new URL(REQ0).origin;
 
67
  promise: NS_ffmpeg.F_probe_v2({
68
  playback_url: new URL(playback),
69
  context: ctx,
70
+ playback_headers, playback_type
71
  })
72
  });
73
 
 
182
  subtitles: subtitles_ary,
183
  out_mime,
184
  probe_data,
185
+ progress_update_endpoint, playback_type
186
  };
187
 
188
  const data_str = devalue.stringify(data);
 
233
  error: () => "Invalid playback headers"
234
  })
235
  ),
236
+ playback_type: t.Optional(
237
+ t.String({
238
+ minLength: 1,
239
+ error() {
240
+ return "Invalid playback type";
241
+ }
242
+ })
243
+ ),
244
  gen: t.Optional(
245
  t.Object(
246
  {
src/sub-router/showtime.ts CHANGED
@@ -171,7 +171,7 @@ async function F_handle_process(arg0: {
171
  subtitles,
172
  out_mime,
173
  probe_data,
174
- progress_update_endpoint
175
  } = start_data;
176
 
177
  const REQ0 = request.url;
@@ -372,7 +372,7 @@ async function F_handle_process(arg0: {
372
  subtitles: subtitles_ary,
373
  has_tcp_progress: tcp_progress,
374
  is_net_src: is_network_source,
375
- playback_headers: playback_headers
376
  });
377
 
378
  if (tcp_progress) {
 
171
  subtitles,
172
  out_mime,
173
  probe_data,
174
+ progress_update_endpoint, playback_type
175
  } = start_data;
176
 
177
  const REQ0 = request.url;
 
372
  subtitles: subtitles_ary,
373
  has_tcp_progress: tcp_progress,
374
  is_net_src: is_network_source,
375
+ playback_headers: playback_headers, playback_type
376
  });
377
 
378
  if (tcp_progress) {