feat: adicionada seleção de timeline do projeto na guia Editar víd
- adicionada seleção de timeline do projeto na guia Editar vídeo Resumo: - 3 arquivos alterados - 0 novos - 3 modificados - 0 removidos 3 files changed, 116 insertions(+), 17 deletions(-) Arquivos: - code/cep-plugin/index.html - code/cep-plugin/main.js - code/cep-plugin/styles.css
This commit is contained in:
@@ -79,18 +79,23 @@
|
|||||||
<span class="step-number" aria-hidden="true">1</span>
|
<span class="step-number" aria-hidden="true">1</span>
|
||||||
<div class="step-title">
|
<div class="step-title">
|
||||||
<h2>Escolher o vídeo</h2>
|
<h2>Escolher o vídeo</h2>
|
||||||
<p>Lê o primeiro clipe da sequência aberta no Premiere.</p>
|
<p>Lista as timelines do projeto e lê o primeiro clipe da escolhida.</p>
|
||||||
</div>
|
</div>
|
||||||
<span class="step-chip" id="step1Chip">Comece aqui</span>
|
<span class="step-chip" id="step1Chip">Comece aqui</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="step-body">
|
<div class="step-body">
|
||||||
<button id="btnDetectClip" class="button button-primary" onclick="silenceDetectClip()" type="button">Detectar sequência ativa</button>
|
<button id="btnDetectClip" class="button button-primary" onclick="silenceListSequences()" type="button">Carregar sequências</button>
|
||||||
|
<div class="sequence-picker" id="silenceSequencePicker" hidden>
|
||||||
|
<label class="field-label" for="silenceSequenceSelect">Escolha a timeline</label>
|
||||||
|
<select id="silenceSequenceSelect" class="select-field" onchange="silenceSelectSequence()"></select>
|
||||||
|
<p class="field-help" id="silenceSequenceListInfo"></p>
|
||||||
|
</div>
|
||||||
<dl class="kv" id="silenceClipCard" hidden>
|
<dl class="kv" id="silenceClipCard" hidden>
|
||||||
<div><dt>Sequência</dt><dd id="clipSequenceName">—</dd></div>
|
<div><dt>Sequência</dt><dd id="clipSequenceName">—</dd></div>
|
||||||
<div><dt>Arquivo</dt><dd id="clipFileName">—</dd></div>
|
<div><dt>Arquivo</dt><dd id="clipFileName">—</dd></div>
|
||||||
<div><dt>Caminho</dt><dd class="kv-path" id="clipMediaPath">—</dd></div>
|
<div><dt>Caminho</dt><dd class="kv-path" id="clipMediaPath">—</dd></div>
|
||||||
</dl>
|
</dl>
|
||||||
<p class="field-help" id="silenceClipInfo">Abra a sequência desejada no Premiere e clique em Detectar.</p>
|
<p class="field-help" id="silenceClipInfo">Abra o projeto no Premiere e carregue as timelines.</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
+106
-14
@@ -1323,6 +1323,7 @@ var LANGUAGE_CATALOG = [
|
|||||||
var DEFAULT_LANGUAGE = "pt";
|
var DEFAULT_LANGUAGE = "pt";
|
||||||
|
|
||||||
var silenceState = {
|
var silenceState = {
|
||||||
|
sequenceId: null,
|
||||||
sequenceName: null,
|
sequenceName: null,
|
||||||
mediaPath: null,
|
mediaPath: null,
|
||||||
fileBaseName: null,
|
fileBaseName: null,
|
||||||
@@ -1442,21 +1443,108 @@ function slugify(name) {
|
|||||||
.replace(/(^-|-$)/g, "") || "video";
|
.replace(/(^-|-$)/g, "") || "video";
|
||||||
}
|
}
|
||||||
|
|
||||||
function silenceDetectClip() {
|
function formatSequenceDuration(seconds) {
|
||||||
|
var total = Math.max(0, Math.round(Number(seconds) || 0));
|
||||||
|
var minutes = Math.floor(total / 60);
|
||||||
|
var remainder = total % 60;
|
||||||
|
return minutes + ":" + String(remainder).padStart(2, "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
function silenceListSequences() {
|
||||||
setBusy("btnDetectClip", true);
|
setBusy("btnDetectClip", true);
|
||||||
setStep(1, "running", "Detectando…");
|
setStep(1, "running", "Carregando…");
|
||||||
document.getElementById("silenceClipInfo").textContent = "Lendo a sequência ativa no Premiere…";
|
document.getElementById("silenceClipInfo").textContent = "Lendo as timelines do projeto…";
|
||||||
cs.evalScript(
|
cs.evalScript(
|
||||||
"(function(){" +
|
"(function(){" +
|
||||||
"try{" +
|
"try{" +
|
||||||
"var seq=app.project.activeSequence;" +
|
"if(!app.project) return JSON.stringify({ok:false,error:'Nenhum projeto aberto.'});" +
|
||||||
"if(!seq) return JSON.stringify({ok:false,error:'Nenhuma sequência ativa.'});" +
|
"var sequences=[];" +
|
||||||
|
"for(var i=0;i<app.project.sequences.numSequences;i++){" +
|
||||||
|
"var seq=app.project.sequences[i];" +
|
||||||
|
"sequences.push({id:String(seq.sequenceID),name:String(seq.name),duration:Number(seq.end.seconds)||0," +
|
||||||
|
"videoTracks:seq.videoTracks.numTracks||0,audioTracks:seq.audioTracks.numTracks||0," +
|
||||||
|
"active:app.project.activeSequence&&seq.sequenceID===app.project.activeSequence.sequenceID});" +
|
||||||
|
"}" +
|
||||||
|
"return JSON.stringify({ok:true,sequences:sequences});" +
|
||||||
|
"}catch(e){return JSON.stringify({ok:false,error:String(e)});}" +
|
||||||
|
"}())",
|
||||||
|
function (raw) {
|
||||||
|
setBusy("btnDetectClip", false);
|
||||||
|
var result;
|
||||||
|
try {
|
||||||
|
result = JSON.parse(raw);
|
||||||
|
} catch (e) {
|
||||||
|
result = { ok: false, error: "Resposta inesperada do Premiere." };
|
||||||
|
}
|
||||||
|
var picker = document.getElementById("silenceSequencePicker");
|
||||||
|
var select = document.getElementById("silenceSequenceSelect");
|
||||||
|
var info = document.getElementById("silenceClipInfo");
|
||||||
|
|
||||||
|
if (!result.ok) {
|
||||||
|
picker.hidden = true;
|
||||||
|
setStep(1, "error", "Não encontrado");
|
||||||
|
info.textContent = result.error || "Não foi possível listar as timelines.";
|
||||||
|
showToast("err", info.textContent);
|
||||||
|
lockStepsFrom(2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!result.sequences || result.sequences.length === 0) {
|
||||||
|
picker.hidden = true;
|
||||||
|
setStep(1, "error", "Sem timelines");
|
||||||
|
info.textContent = "O projeto não possui timelines.";
|
||||||
|
showToast("err", info.textContent);
|
||||||
|
lockStepsFrom(2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.innerHTML = "";
|
||||||
|
result.sequences.forEach(function (sequence) {
|
||||||
|
var option = document.createElement("option");
|
||||||
|
option.value = sequence.id;
|
||||||
|
option.textContent = sequence.name + " · " + formatSequenceDuration(sequence.duration) +
|
||||||
|
" · V" + sequence.videoTracks + " / A" + sequence.audioTracks +
|
||||||
|
(sequence.active ? " · ativa" : "");
|
||||||
|
option.dataset.sequence = JSON.stringify(sequence);
|
||||||
|
select.appendChild(option);
|
||||||
|
});
|
||||||
|
var activeIndex = -1;
|
||||||
|
for (var sequenceIndex = 0; sequenceIndex < result.sequences.length; sequenceIndex++) {
|
||||||
|
if (result.sequences[sequenceIndex].active) {
|
||||||
|
activeIndex = sequenceIndex;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
select.selectedIndex = activeIndex >= 0 ? activeIndex : 0;
|
||||||
|
picker.hidden = false;
|
||||||
|
document.getElementById("silenceSequenceListInfo").textContent =
|
||||||
|
result.sequences.length + " timeline(s) encontrada(s).";
|
||||||
|
silenceSelectSequence();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function silenceSelectSequence() {
|
||||||
|
var select = document.getElementById("silenceSequenceSelect");
|
||||||
|
var option = select && select.options[select.selectedIndex];
|
||||||
|
if (!option || !option.dataset.sequence) return;
|
||||||
|
var sequence = JSON.parse(option.dataset.sequence);
|
||||||
|
setBusy("btnDetectClip", true);
|
||||||
|
setStep(1, "running", "Lendo timeline…");
|
||||||
|
document.getElementById("silenceClipInfo").textContent = "Lendo o primeiro clipe da timeline escolhida…";
|
||||||
|
var sequenceId = JSON.stringify(String(sequence.id));
|
||||||
|
cs.evalScript(
|
||||||
|
"(function(){" +
|
||||||
|
"try{" +
|
||||||
|
"var sequenceId=" + sequenceId + ";" +
|
||||||
|
"var seq=null;" +
|
||||||
|
"for(var i=0;i<app.project.sequences.numSequences;i++){if(String(app.project.sequences[i].sequenceID)===sequenceId){seq=app.project.sequences[i];break;}}" +
|
||||||
|
"if(!seq) return JSON.stringify({ok:false,error:'Timeline não encontrada.'});" +
|
||||||
"var vt=seq.videoTracks[0];" +
|
"var vt=seq.videoTracks[0];" +
|
||||||
"if(!vt||vt.clips.numItems===0) return JSON.stringify({ok:false,error:'Vídeo 1 está vazio na sequência ativa.'});" +
|
"if(!vt||vt.clips.numItems===0) return JSON.stringify({ok:false,error:'Vídeo 1 está vazio nesta timeline.'});" +
|
||||||
"var clip=vt.clips[0];" +
|
"var clip=vt.clips[0];" +
|
||||||
"var projItem=clip.projectItem;" +
|
"var projItem=clip.projectItem;" +
|
||||||
"var mediaPath=projItem&&projItem.getMediaPath?projItem.getMediaPath():'';" +
|
"var mediaPath=projItem&&projItem.getMediaPath?projItem.getMediaPath():'';" +
|
||||||
"return JSON.stringify({ok:true,sequenceName:seq.name,mediaPath:mediaPath,clipName:clip.name});" +
|
"return JSON.stringify({ok:true,sequenceId:String(seq.sequenceID),sequenceName:seq.name,mediaPath:mediaPath,clipName:clip.name});" +
|
||||||
"}catch(e){return JSON.stringify({ok:false,error:String(e)});}" +
|
"}catch(e){return JSON.stringify({ok:false,error:String(e)});}" +
|
||||||
"}())",
|
"}())",
|
||||||
function (raw) {
|
function (raw) {
|
||||||
@@ -1472,14 +1560,14 @@ function silenceDetectClip() {
|
|||||||
|
|
||||||
if (!result.ok || !result.mediaPath) {
|
if (!result.ok || !result.mediaPath) {
|
||||||
card.hidden = true;
|
card.hidden = true;
|
||||||
setStep(1, "error", "Não encontrado");
|
setStep(1, "error", "Sem mídia");
|
||||||
info.textContent = (result.error || "Caminho de mídia vazio.") +
|
info.textContent = result.error || "Caminho de mídia vazio.";
|
||||||
" Abra a sequência no Premiere e tente de novo.";
|
showToast("err", info.textContent);
|
||||||
showToast("err", result.error || "Não foi possível ler a sequência ativa.");
|
|
||||||
lockStepsFrom(2);
|
lockStepsFrom(2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
silenceState.sequenceId = result.sequenceId;
|
||||||
silenceState.sequenceName = result.sequenceName;
|
silenceState.sequenceName = result.sequenceName;
|
||||||
silenceState.mediaPath = result.mediaPath;
|
silenceState.mediaPath = result.mediaPath;
|
||||||
silenceState.fileBaseName = slugify(result.clipName || result.sequenceName);
|
silenceState.fileBaseName = slugify(result.clipName || result.sequenceName);
|
||||||
@@ -1498,18 +1586,22 @@ function silenceDetectClip() {
|
|||||||
card.hidden = false;
|
card.hidden = false;
|
||||||
info.textContent = "";
|
info.textContent = "";
|
||||||
|
|
||||||
setStep(1, "done", "Vídeo escolhido");
|
setStep(1, "done", "Timeline escolhida");
|
||||||
lockStepsFrom(2);
|
lockStepsFrom(2);
|
||||||
setStep(2, "ready", "Sua vez");
|
setStep(2, "ready", "Sua vez");
|
||||||
document.getElementById("btnTranscribe").disabled = false;
|
document.getElementById("btnTranscribe").disabled = false;
|
||||||
document.getElementById("silenceJsonCard").hidden = true;
|
document.getElementById("silenceJsonCard").hidden = true;
|
||||||
document.getElementById("silencePlanInfo").textContent = "";
|
document.getElementById("silencePlanInfo").textContent = "";
|
||||||
silenceLog("Clipe detectado: " + result.mediaPath);
|
silenceLog("Timeline escolhida: " + result.sequenceName + " — " + result.mediaPath);
|
||||||
renderCachedTranscripts();
|
renderCachedTranscripts();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function silenceDetectClip() {
|
||||||
|
silenceListSequences();
|
||||||
|
}
|
||||||
|
|
||||||
// Volta os passos seguintes ao estado travado quando o vídeo (ou a transcrição)
|
// Volta os passos seguintes ao estado travado quando o vídeo (ou a transcrição)
|
||||||
// muda — evita aplicar um plano gerado para outro material.
|
// muda — evita aplicar um plano gerado para outro material.
|
||||||
function lockStepsFrom(first) {
|
function lockStepsFrom(first) {
|
||||||
@@ -2029,7 +2121,7 @@ function applyEditorialActions() {
|
|||||||
silenceLog("Aplicando plano de edição na timeline…");
|
silenceLog("Aplicando plano de edição na timeline…");
|
||||||
runStreamed(
|
runStreamed(
|
||||||
nodeBin,
|
nodeBin,
|
||||||
[applyScript, "--plan", planPath, "--sequence", silenceState.sequenceName],
|
[applyScript, "--plan", planPath, "--sequence", silenceState.sequenceId || silenceState.sequenceName],
|
||||||
function (line) { silenceLog(line); },
|
function (line) { silenceLog(line); },
|
||||||
function (code, lastErr) {
|
function (code, lastErr) {
|
||||||
setBusy("btnApplyEditorialActions", false);
|
setBusy("btnApplyEditorialActions", false);
|
||||||
|
|||||||
@@ -388,6 +388,8 @@ textarea { padding: 8px 10px; font: 10px var(--font-mono); color: var(--text-sec
|
|||||||
.kv dt { flex: 0 0 62px; color: var(--text-muted); font-size: 9px; }
|
.kv dt { flex: 0 0 62px; color: var(--text-muted); font-size: 9px; }
|
||||||
.kv dd { flex: 1; min-width: 0; overflow: hidden; margin: 0; color: var(--text); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
|
.kv dd { flex: 1; min-width: 0; overflow: hidden; margin: 0; color: var(--text); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
.kv .kv-path { color: var(--text-muted); font: 9px var(--font-mono); }
|
.kv .kv-path { color: var(--text-muted); font: 9px var(--font-mono); }
|
||||||
|
.sequence-picker { margin-top: 10px; }
|
||||||
|
.sequence-picker[hidden] { display: none; }
|
||||||
|
|
||||||
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
|
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
|
||||||
.stat-row[hidden] { display: none; }
|
.stat-row[hidden] { display: none; }
|
||||||
|
|||||||
Reference in New Issue
Block a user