OrbiSubs: live WebVTT subtitles for an HLS channel (whisper.cpp HTTP or faster-whisper)
Video -c:v copy, audio AAC re-encode, VTT por segmento alineado por PTS, video sostenido hasta tener subtítulo. Prueba tarea 076 en pve7 CT 176.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<!doctype html>
|
||||
<html lang="es"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>OrbiSubs prueba</title>
|
||||
<style>body{background:#111;color:#ddd;font-family:sans-serif;margin:16px}video{width:100%;max-width:960px}
|
||||
#info{font-size:13px;color:#999;margin-top:8px}select,input{font-size:14px}</style></head>
|
||||
<body>
|
||||
<h3>OrbiSubs — subtítulos en vivo (prueba)</h3>
|
||||
<input id="u" size="50" value="/hls/t13/master.m3u8"> <button onclick="cargar()">Cargar</button>
|
||||
<label> Subtítulos <select id="s"><option value="-1">Apagados</option></select></label>
|
||||
<div><video id="v" controls muted autoplay playsinline></video></div>
|
||||
<div id="info"></div>
|
||||
<div id="diag" style="font-size:12px;color:#777"></div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.5.20/dist/hls.min.js"></script>
|
||||
<script>
|
||||
let hls;
|
||||
function cargar(){
|
||||
const v=document.getElementById('v'), s=document.getElementById('s');
|
||||
if(hls) hls.destroy();
|
||||
hls=new Hls({liveSyncDurationCount:3});
|
||||
// Recuperación estándar de hls.js: el CDN de origen mete cortes de PTS en las tandas
|
||||
// y el decoder del navegador a veces se cae ahí (visto con Chromium, 2026-11-16).
|
||||
hls.on(Hls.Events.ERROR,(e,d)=>{ if(!d.fatal) return;
|
||||
if(d.type===Hls.ErrorTypes.MEDIA_ERROR) hls.recoverMediaError(); else hls.startLoad(); });
|
||||
hls.loadSource(document.getElementById('u').value); hls.attachMedia(v);
|
||||
hls.on(Hls.Events.SUBTITLE_TRACKS_UPDATED,()=>{
|
||||
s.innerHTML='<option value="-1">Apagados</option>'+hls.subtitleTracks.map((t,i)=>`<option value="${i}">${t.name}</option>`).join('');
|
||||
s.value=0; hls.subtitleTrack=0; hls.subtitleDisplay=true;
|
||||
});
|
||||
s.onchange=()=>{hls.subtitleTrack=+s.value; hls.subtitleDisplay=+s.value>=0;};
|
||||
// Diagnóstico: cuántos cues cargó la pista y cuál está en pantalla (sirve para
|
||||
// probar con un navegador headless que el texto llega y en qué tiempo del video).
|
||||
setInterval(()=>{const t=[...v.textTracks].find(x=>x.mode==='showing');
|
||||
const act=t&&t.activeCues&&t.activeCues.length?[...t.activeCues].map(c=>c.text.replace(/\n/g,' ')).join(' / '):'';
|
||||
document.getElementById('diag').textContent=`t=${v.currentTime.toFixed(1)} pistas=${v.textTracks.length} cues=${t&&t.cues?t.cues.length:0} activo=[${act}]`;},500);
|
||||
setInterval(()=>{const l=hls.latency; document.getElementById('info').textContent=
|
||||
'Retraso al borde de la lista publicada: '+(l?l.toFixed(1):'?')+' s';},1000);
|
||||
}
|
||||
cargar();
|
||||
</script></body></html>
|
||||
Reference in New Issue
Block a user