xvai-loi 0.1.77 → 0.1.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/co.txt +1 -1
  2. package/package.json +1 -1
  3. package/xvai-loi.js +66 -18
package/co.txt CHANGED
@@ -1 +1 @@
1
- xvaiLoi112314
1
+ xvaiLoi120008
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xvai-loi",
3
- "version": "0.1.77",
3
+ "version": "0.1.79",
4
4
  "description": "Loi dung video (Edit Video Tu Dong) nap vao tool Google Flow qua o cam engine/oCam.ts",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/xvai-loi.js CHANGED
@@ -9822,10 +9822,11 @@ var KHUON_TOPN = {
9822
9822
  ten: "Top N chi\u1EC1u s\xE2u (Captions)",
9823
9823
  tram: { phut: 18.3, tyLe: 0.7, phan: [0.83, 0.81, 0.46], daiTV: 2.1, video: 0.33, nhanVat: ["Vietnamese people in a real everyday setting.", "Close-up of an object, hands or a place that shows the idea, no faces."] },
9824
9824
  // cảnh trám / phút, % thời lượng, 3 phần đầu/giữa/cuối, độ dài trung vị (s), tỉ lệ clip động; nhanVat: xen kẽ ảnh có người / cận vật-tay-nơi (đối thủ trộn web, stock, 3D — B06-1027: toàn ảnh người → 'không thấy mặt' 12 % < 15)
9825
- chu: { phut: [8, 18] },
9825
+ chu: { phut: [8, 18], caoMin: 0.042 },
9826
+ // caoMin: nét chữ nhấn (kể cả dấu) / H — đối thủ trung vị 0,042 (đo tay 23 dòng); chữ bị ép ngang thấp hơn → 2 dòng
9826
9827
  icon: { phut: 11.5 },
9827
- cat: { moi10s: [4, 6], manhNguoi: 1.2 },
9828
- // manhNguoi: mẩu người nói kẹp giữa 2 cảnh ngắn hơn thì lấp (trước 0,6 — VD-236)
9828
+ cat: { moi10s: [4, 6], manhNguoi: 1.2, heChu: 0 },
9829
+ // manhNguoi: mẩu người nói kẹp giữa 2 cảnh ngắn hơn thì lấp (trước 0,6 — VD-236); heChu: khe giữa 2 cảnh liền cùng có chữ (trước 0,06 → chớp 2 khung người nói = 2 cú cắt thừa; bàn thử 13 video 12/10 00:0x: 0,06 → 0 cắt TB 5,44 → 4,39/10 s, chồng chữ 0/13 — cảnh trước đã hết theo giờ PHIM nhờ bT)
9829
9830
  nguoi: { phongToiDa: 1.8, matToiDa: 0.55 },
9830
9831
  // matToiDa: hộp đầu (tóc→cằm) cao hơn 0,55 H thì KHÔNG dùng ô người / chia (không vừa ô) // MỌI ô người (PIP, thẻ, chia) phóng khung gốc tối đa 1,8× (độ nét) — trước: PIP 1,6, thẻ 1,3 (B05-1027: thẻ hiện cả người nhỏ)
9831
9832
  lietKe: { xenKe: 2 },
@@ -9992,6 +9993,27 @@ function kieuChu() {
9992
9993
  kcCache = k || {};
9993
9994
  return kcCache;
9994
9995
  }
9996
+ function haiDong4(g, txt, px, maxW, pxMin, pxMax) {
9997
+ const t = txt.normalize("NFC"), ws = t.split(/\s+/).filter(Boolean);
9998
+ if (t.indexOf(String.fromCharCode(10)) >= 0 || ws.length < 3) return [t, px, t.indexOf(String.fromCharCode(10)) >= 0];
9999
+ g.save();
10000
+ g.font = "900 " + px.toFixed(1) + "px " + FB;
10001
+ const w = g.measureText(t).width;
10002
+ if (px * Math.min(1, maxW / w) >= pxMin) {
10003
+ g.restore();
10004
+ return [t, px, false];
10005
+ }
10006
+ let tot = "", m = 1e9;
10007
+ for (let i = 1; i < ws.length; i++) {
10008
+ const a = ws.slice(0, i).join(" "), b = ws.slice(i).join(" "), x = Math.max(g.measureText(a).width, g.measureText(b).width);
10009
+ if (x < m) {
10010
+ m = x;
10011
+ tot = a + String.fromCharCode(10) + b;
10012
+ }
10013
+ }
10014
+ g.restore();
10015
+ return [tot, Math.min(pxMax, px * Math.min(1, maxW / m)), true];
10016
+ }
9995
10017
  function chu2(g, txt, x, y, px, kieu, a = 1, maxW = 0) {
9996
10018
  if (!txt || a <= 0) return;
9997
10019
  txt = String(txt).normalize("NFC");
@@ -10806,19 +10828,21 @@ dangKy("cmNen", (g, d, tuoi, W4, H2, nen2, _s, dai2) => {
10806
10828
  if (hv2 > 0) g.drawImage(vt, W4 / 2 - wv / 2, yv - hv2 / 2, wv, hv2);
10807
10829
  g.restore();
10808
10830
  }
10809
- if (d.tieu) chu2(g, d.tieu, W4 / 2, 0.135 * H2 + (1 - ka) * 70 * H2 / 1920, 122 * H2 / 1920, "brand", kep12(tuoi / 0.15), 0.76 * W4);
10831
+ const t2 = d.tieu ? haiDong4(g, String(d.tieu), 122 * H2 / 1920, 0.76 * W4, KHUON_TOPN.chu.caoMin / 0.92 * H2, 0.05 * H2) : null;
10832
+ if (t2) chu2(g, t2[0], W4 / 2, (t2[2] ? 0.118 : 0.135) * H2 + (1 - ka) * 70 * H2 / 1920, t2[1], "brand", kep12(tuoi / 0.15), 0.76 * W4);
10810
10833
  if (d.so) {
10811
10834
  g.save();
10812
10835
  g.globalAlpha = a * kep12((tuoi - 0.15) / 0.2);
10813
10836
  g.font = "900 " + (0.02 * H2).toFixed(1) + "px " + FB;
10814
10837
  const t = (d.nhom || "M\u1EE4C") + " " + d.so + "/" + d.N, tw = g.measureText(t).width + 0.05 * W4;
10815
- bo(g, W4 / 2 - tw / 2, 0.172 * H2, tw, 0.034 * H2, 0.017 * H2);
10838
+ const dy = t2 && t2[2] ? 0.01 * H2 : 0;
10839
+ bo(g, W4 / 2 - tw / 2, 0.172 * H2 + dy, tw, 0.034 * H2, 0.017 * H2);
10816
10840
  g.fillStyle = "rgba(20,20,26,0.85)";
10817
10841
  g.fill();
10818
10842
  g.fillStyle = VANG;
10819
10843
  g.textAlign = "center";
10820
10844
  g.textBaseline = "middle";
10821
- g.fillText(t, W4 / 2, 0.189 * H2);
10845
+ g.fillText(t, W4 / 2, 0.189 * H2 + dy);
10822
10846
  g.restore();
10823
10847
  }
10824
10848
  if (d.ui) theUI(g, d.ui, tuoi, W4, H2, 1);
@@ -11412,7 +11436,7 @@ function cum2(ws) {
11412
11436
  for (let i = w.length - 2; i >= 0; i--) if (!hu(w[i]) && !hu(w[i + 1])) return w[i] + " " + w[i + 1];
11413
11437
  return w.slice(-2).join(" ");
11414
11438
  }
11415
- var haiDong4 = (s, n = 10) => {
11439
+ var haiDong5 = (s, n = 10) => {
11416
11440
  const w = s.split(" ");
11417
11441
  if (s.length <= n || w.length < 2) return s;
11418
11442
  let best = 1, d = 99;
@@ -11781,7 +11805,7 @@ function lapCuongMe(o) {
11781
11805
  })(sach3(kb?.moc || layMoc(ws, kb)).split(" "))) || hoa3(cum2(cs[0] ? cs[0].chu : []));
11782
11806
  const Lm = Math.min(Math.max(2.4, docGiay(moc) + 0.4), Math.max(1.2, f1 - 0.3));
11783
11807
  bc = "B2 moc";
11784
- de(0, Lm, { uuTien: UT.moc, bo: "depth", giant: haiDong4(moc, 11), chu2: coBuoc ? N + " " + LOAI2 : "", yChu: 0.165, vao: 1e-3, z: 1.3, keu: "whoosh" });
11808
+ de(0, Lm, { uuTien: UT.moc, bo: "depth", giant: haiDong5(moc, 11), chu2: coBuoc ? N + " " + LOAI2 : "", yChu: 0.165, vao: 1e-3, z: 1.3, keu: "whoosh" });
11785
11809
  if (coBuoc && f1 - Lm > 3.4) de(Lm + 0.3, Math.min(3.2, f1 - Lm - 0.6), { uuTien: UT.moc, bo: "cut", tieu: N + " " + LOAI2, hang: muc.map((m) => m.ten).slice(0, 8), keu: "pop", st: "chuot", stX: 0.43, stY: 0.188, stR: 0.042, stTre: 1.2 });
11786
11810
  else if (N >= 2) ghiL("bo", { bo: "cut", f: Lm + 0.3, d: 3.2 }, "moc ngan (f1 - Lm <= 3,4 s) \u2192 bo hang N muc");
11787
11811
  const gonTen = (x) => {
@@ -11800,7 +11824,7 @@ function lapCuongMe(o) {
11800
11824
  const c = cs.filter((x) => x.f >= m.f + Lc + 2 && x.f + 2.4 <= m.b - 1).sort((p, q) => Math.abs(p.f - (m.f + L * 0.6)) - Math.abs(q.f - (m.f + L * 0.6)))[0];
11801
11825
  if (c) {
11802
11826
  const t = hoa3(cum2(c.chu));
11803
- de(c.f, Math.max(2.2, docGiay(t) + 0.6), { uuTien: UT.chu, bo: "depth", giant: haiDong4(t, 9), keu: "pop" });
11827
+ de(c.f, Math.max(2.2, docGiay(t) + 0.6), { uuTien: UT.chu, bo: "depth", giant: haiDong5(t, 9), keu: "pop" });
11804
11828
  }
11805
11829
  }
11806
11830
  });
@@ -11816,7 +11840,7 @@ function lapCuongMe(o) {
11816
11840
  if (iN >= 0 && ws[iN + 2] && /^[A-ZÀ-Ỹ]/.test(String(ws[iN + 2].text || "").trim())) {
11817
11841
  const nm = [];
11818
11842
  for (let k = iN + 2; k < W22.length && nm.length < 4 && !DUNG.test(W22[k].t) && !/^(nhớ|hãy|bấm)$/.test(W22[k].t); k++) nm.push(W22[k].t);
11819
- if (nm.length) de(W22[iN].f, 1.8, { uuTien: UT.cta, bo: "depth", giant: haiDong4(hoa3(suaChu(nm.join(" "))), 9), keu: "pop" }, 0.5);
11843
+ if (nm.length) de(W22[iN].f, 1.8, { uuTien: UT.cta, bo: "depth", giant: haiDong5(hoa3(suaChu(nm.join(" "))), 9), keu: "pop" }, 0.5);
11820
11844
  }
11821
11845
  if (iC >= 0) de(fC, 2.4, { uuTien: UT.cta, bo: "depth", giant: W22[iC].t === "comment" ? "COMMENT" : "B\xCCNH LU\u1EACN", yChu: 0.17, chu2: kw.length ? '"' + hoa3(kw.filter((w, i) => i === 0 || String(w).toLocaleLowerCase("vi") !== String(kw[i - 1]).toLocaleLowerCase("vi")).join(" ")) + '"' : "", keu: "pop" }, 1);
11822
11846
  if (iL >= 0) de(W22[iL].f, 2, { uuTien: UT.cta, bo: "cut", giant: "L\u01AFU VIDEO", st: "luu", keu: "pop" }, 1);
@@ -11906,7 +11930,7 @@ function lapCuongMe(o) {
11906
11930
  else if (x.kieu === "vat") {
11907
11931
  const LG = timLogo(suaChu(chuK + " " + sach3(String(x.tu || ""))))[0];
11908
11932
  if (LG) napHinhLogo(LG.slug);
11909
- de(f2, 2.3, { uuTien: UT.vat, bo: "cut", vat: co && !LG ? ten2 : "", logoTo: LG, giant: haiDong4(chuK, 11), chu2: co || LG ? "" : chu22, keu: "pop" }, 3);
11933
+ de(f2, 2.3, { uuTien: UT.vat, bo: "cut", vat: co && !LG ? ten2 : "", logoTo: LG, giant: haiDong5(chuK, 11), chu2: co || LG ? "" : chu22, keu: "pop" }, 3);
11910
11934
  } else if (x.kieu === "ds" && Array.isArray(x.dong) && x.dong.length >= 2) {
11911
11935
  const dg = x.dong.slice(0, 3).map((v) => hoa3(suaChu(sach3(String(v || "")))).split(" ").slice(0, 6).join(" ")).filter(Boolean);
11912
11936
  const qs = dg.map((v) => {
@@ -11916,7 +11940,7 @@ function lapCuongMe(o) {
11916
11940
  dg.splice(0, 9, ...dg2);
11917
11941
  de(f2, Math.max(2.4, Math.min(3.4, (moc2.filter((v) => v != null).pop() || 1) + 1.3)), { uuTien: UT.ds, bo: "kinh", dong: dg, moc: moc2, ten: co ? ten2 : "", keu: "whoosh" }, 3);
11918
11942
  } else if (x.kieu === "so") de(f2, 2.2, { uuTien: UT.so, bo: "cut", giant: chuK, cam: 1, chu2: chu22, keu: "pop" }, 3);
11919
- else if (chuK) de(f2, Math.max(2, docGiay(chuK) + 0.6), { uuTien: UT.chu, bo: "depth", giant: haiDong4(chuK, 9), keu: "pop" }, 3);
11943
+ else if (chuK) de(f2, Math.max(2, docGiay(chuK) + 0.6), { uuTien: UT.chu, bo: "depth", giant: haiDong5(chuK, 9), keu: "pop" }, 3);
11920
11944
  if (ung.length === n0 && x.kieu !== "anh") {
11921
11945
  boC.push([chuK || x.tu, +f2.toFixed(2), "khong-dat", x.kieu]);
11922
11946
  if (loai.length === n1) ghiL("bo", { bo: x.kieu || "chu", f: f2, d: 0 }, "khong goi dat(): ds < 2 dong hoac khong co chu: " + String(x.tu || ""));
@@ -11994,7 +12018,7 @@ function lapCuongMe(o) {
11994
12018
  if (k < 2) k = kc;
11995
12019
  if (k < 2) return;
11996
12020
  const t3 = hoa3(suaChu([k - 2, k - 1, k].map((q) => sach3(ws[q].text)).join(" "))), f32 = Math.max(a + 0.3, Math.min(W22[k - 2].f - 0.1, b - 1.9));
11997
- if (t3) dat(f32, Math.max(1.3, Math.min(2.1, b - f32 - 0.16)), { bo: "depth", giant: haiDong4(t3, 11), keu: "pop" }, 0.5);
12021
+ if (t3) dat(f32, Math.max(1.3, Math.min(2.1, b - f32 - 0.16)), { bo: "depth", giant: haiDong5(t3, 11), keu: "pop" }, 0.5);
11998
12022
  });
11999
12023
  }
12000
12024
  sp.sort((p, q) => p.f - q.f).forEach((s, k) => {
@@ -12035,7 +12059,7 @@ function lapCuongMe(o) {
12035
12059
  const p = sp[k - 1], q = sp[k], cl = (s) => !!(s.giant || s.tieu || s.dong || s.ui || s.doc || s.chu);
12036
12060
  if (p.bo === "kinh" && q.bo === "kinh" && q.f - p.f - p.d < 1) {
12037
12061
  ghiL("rut-dong", q, "2 the kinh lien < 1 s \u2192 khung tron, mat dong 2-3");
12038
- q.bo = "tron", q.giant = haiDong4(String((q.dong || [])[0] || ""), 11);
12062
+ q.bo = "tron", q.giant = haiDong5(String((q.dong || [])[0] || ""), 11);
12039
12063
  }
12040
12064
  if (cl(p) && cl(q) && q.f - p.f - p.d < 1 && q.f - p.f - 1 >= 1.2) {
12041
12065
  ghiL("rut", p, "2 canh chu lien < 1 s \u2192 ve mat + phu de >= 1 s", [p.f, q.f - 1]);
@@ -12443,7 +12467,7 @@ function lapCuongMe(o) {
12443
12467
  }
12444
12468
  if (dg.length >= 3) ghiL("rut-dong", s, "qua 3 the kinh \u2192 chu sau dau / nen toi, mat dong 3");
12445
12469
  s.bo = xen++ % 2 ? "cut" : "depth";
12446
- s.giant = haiDong4(String(dg[0] || ""), 9);
12470
+ s.giant = haiDong5(String(dg[0] || ""), 9);
12447
12471
  s.chu2 = dg[1] || "";
12448
12472
  if (s.bo === "cut") s.toiNen = 1;
12449
12473
  s.dong = void 0;
@@ -12508,7 +12532,7 @@ function lapCuongMe(o) {
12508
12532
  v.vat = v.ten;
12509
12533
  v.ten = "";
12510
12534
  v.vatChia = 0;
12511
- v.giant = haiDong4(String(v.chu || ""), 11);
12535
+ v.giant = haiDong5(String(v.chu || ""), 11);
12512
12536
  v.chu = "";
12513
12537
  v.st = v.st0;
12514
12538
  return true;
@@ -12953,6 +12977,30 @@ function lapCuongMe(o) {
12953
12977
  });
12954
12978
  }
12955
12979
  }
12980
+ {
12981
+ const coC = (x) => x.bo !== "phong" && !!String(x.giant || x.chu || x.tieu || "").trim(), C2 = sp.filter(coC).sort((p, q) => p.f - q.f), tran = Math.floor(0.9 * KHUON_TOPN.chu.phut[1] * tong / 60);
12982
+ let nT = 0;
12983
+ while (C2.length > tran) {
12984
+ let j = -1, m = 1e9;
12985
+ for (let k = 0; k < C2.length; k++) {
12986
+ const x = C2[k];
12987
+ if (x.bo !== "anh" || x.f < 3 || x.khoa) continue;
12988
+ const g = Math.min(k > 0 ? x.f - C2[k - 1].f : 1e9, k + 1 < C2.length ? C2[k + 1].f - x.f : 1e9);
12989
+ if (g < m) {
12990
+ m = g;
12991
+ j = k;
12992
+ }
12993
+ }
12994
+ if (j < 0) break;
12995
+ ghiL("doi", C2[j], "khuon chu.phut: bo chu " + String(C2[j].chu || C2[j].giant || "").slice(0, 20));
12996
+ C2[j].chu = "";
12997
+ C2[j].chu2 = "";
12998
+ C2[j].giant = "";
12999
+ C2.splice(j, 1);
13000
+ nT++;
13001
+ }
13002
+ G4.__tiaChu = nT;
13003
+ }
12956
13004
  G4.__lichSp = sp.map((s, i) => ({ i, id: s.id, yChu: s.yChu, coChu: s.coChu, fx: s.fx, stX: s.stX, stY: s.stY, f: +s.f.toFixed(2), d: +s.d.toFixed(2), bo: s.bo, giant: s.giant || "", chu: s.chu || "", chu2: s.chu2 || "", st: s.st || "", ten: s.ten || "", tieu: s.tieu || "", khoa: s.khoa ? 1 : 0 }));
12957
13005
  }
12958
13006
  const thanhO = (t) => coBuoc && t >= f1 - 0.1 && t < hetMuc;
@@ -12967,7 +13015,7 @@ function lapCuongMe(o) {
12967
13015
  const cc = sp.filter((x) => x.bo !== "phong").sort((p, q) => p.f - q.f);
12968
13016
  for (let i = 0; i + 1 < cc.length; i++) {
12969
13017
  const x = cc[i], y = cc[i + 1];
12970
- const coChu = (z) => !!String(z.giant || z.chu || z.tieu || "").trim(), he = coChu(x) && coChu(y) ? 0.06 : 0;
13018
+ const coChu = (z) => !!String(z.giant || z.chu || z.tieu || "").trim(), he = coChu(x) && coChu(y) ? globalThis.__heChu ?? KHUON_TOPN.cat.heChu : 0;
12971
13019
  if (x.f + x.d > y.f - he && y.f > x.f + 0.3 && !x.khoa) {
12972
13020
  if (he) ghiL("doi", x, "N8: cat duoi " + (x.f + x.d - y.f + he).toFixed(2) + " s chong canh sau (2 chu cung hien)");
12973
13021
  x.d = +(y.f - x.f - he).toFixed(2);
@@ -20839,7 +20887,7 @@ function datCauLenh(a) {
20839
20887
  on2 = true;
20840
20888
  window.addEventListener("message", async (ev) => {
20841
20889
  const d = ev.data;
20842
- if (!d || d.xvaiLoi112314 !== true) return;
20890
+ if (!d || d.xvaiLoi120008 !== true) return;
20843
20891
  const o = String(ev.origin || "");
20844
20892
  if (!(o.indexOf("https://flow.google.com") === 0 || o.indexOf("https://labs.google") === 0)) return;
20845
20893
  const tra = (kq) => {