diff --git a/public/app.js b/public/app.js index 192d10c..a0caed5 100644 --- a/public/app.js +++ b/public/app.js @@ -2243,46 +2243,10 @@ currentExportSessionId = transcodeStartRes.sessionId; // Step 3: Monitor Server FFmpeg Transcode - exportStatusText.textContent = `Server transcodiert ${format === 'prores' ? 'Apple ProRes 4444 (10-Bit Alpha)' : (format === 'qtrle' ? 'Lossless QuickTime RLE' : 'Master Video')}...`; + exportStatusText.textContent = `Server transcodiert Master Video...`; if (exportFpsLive) exportFpsLive.textContent = 'FFmpeg Multi-Thread Encoding...'; - let finishData = null; - while (!finishData && !isExportCancelled) { - await new Promise(r => setTimeout(r, 800)); - - const statusRes = await fetch(`/api/export/status/${currentExportSessionId}`); - if (!statusRes.ok) { - const errData = await statusRes.json().catch(() => ({})); - throw new Error(errData.error || 'Fehler beim Abrufen des Video-Status'); - } - - const statusJson = await statusRes.json(); - if (statusJson.status === 'ready') { - finishData = statusJson; - break; - } else if (statusJson.status === 'error') { - throw new Error(statusJson.error || 'FFmpeg Transcoder-Fehler auf dem Server'); - } else { - const mb = (statusJson.sizeBytes / 1024 / 1024).toFixed(1); - exportStatusText.textContent = `Schreibe Master-Datei auf Server (${mb} MB)...`; - } - } - - if (isExportCancelled) throw new Error('Export durch Benutzer abgebrochen'); - - // Trigger automatic download - const downloadLink = document.createElement('a'); - downloadLink.style.display = 'none'; - downloadLink.href = finishData.downloadUrl; - downloadLink.download = finishData.filename; - document.body.appendChild(downloadLink); - downloadLink.click(); - setTimeout(() => { - document.body.removeChild(downloadLink); - }, 5000); - - const finalMb = (finishData.sizeBytes / 1024 / 1024).toFixed(1); - alert(`🎉 Fertig! Dein Studio-Master "${finishData.filename}" (${finalMb} MB) wurde erfolgreich transcodiert und heruntergeladen.`); + await monitorServerSession(currentExportSessionId, format); return; } @@ -2414,11 +2378,15 @@ } // Poll status until ready + await monitorServerSession(currentExportSessionId, format); + } + + async function monitorServerSession(sessionId, format) { let finishData = null; while (!finishData && !isExportCancelled) { - await new Promise(r => setTimeout(r, 600)); + await new Promise(r => setTimeout(r, 1000)); - const statusRes = await fetch(`/api/export/status/${currentExportSessionId}`); + const statusRes = await fetch(`/api/export/status/${sessionId}`); if (!statusRes.ok) { const errData = await statusRes.json().catch(() => ({})); throw new Error(errData.error || 'Fehler beim Abrufen des Video-Status'); @@ -2432,25 +2400,15 @@ throw new Error(statusJson.error || 'FFmpeg Encoder-Fehler auf dem Server'); } else { const mb = (statusJson.sizeBytes / 1024 / 1024).toFixed(1); - exportStatusText.textContent = `Finalisiere Video (${mb} MB geschrieben)...`; - if (exportFpsLive) exportFpsLive.textContent = 'Schreibe Datei auf Festplatte...'; + exportStatusText.textContent = `Server verarbeitet Render-Job (${mb} MB geschrieben)...`; + if (exportFpsLive) exportFpsLive.textContent = 'Warten auf FFmpeg...'; } } if (isExportCancelled) throw new Error('Export durch Benutzer abgebrochen'); - // Automatic Download Trigger - const downloadLink = document.createElement('a'); - downloadLink.style.display = 'none'; - downloadLink.href = finishData.downloadUrl; - downloadLink.download = finishData.filename; - document.body.appendChild(downloadLink); - downloadLink.click(); - setTimeout(() => { - document.body.removeChild(downloadLink); - }, 1000); - - alert(`🎉 Fertig! Dein Video "${finishData.filename}" wurde in makelloser Studio-Qualität gerendert.`); + fetchRenderHistory(); // Refresh the UI list + alert(`🎉 Fertig! Das Rendering ist abgeschlossen. Wähle nun im Render-Verlauf dein gewünschtes Format zum Herunterladen aus.`); } async function startExport() { @@ -2772,6 +2730,11 @@ }); btnCancelExport.addEventListener('click', cancelExport); + const btnRefreshHistory = document.getElementById('btnRefreshHistory'); + if (btnRefreshHistory) { + btnRefreshHistory.addEventListener('click', fetchRenderHistory); + } + window.addEventListener('keydown', (e) => { if (e.code === 'Space' && e.target.tagName !== 'INPUT') { e.preventDefault(); @@ -2780,12 +2743,96 @@ }); } + async function fetchRenderHistory() { + try { + const res = await fetch('/api/export/history'); + const history = await res.json(); + const listContainer = document.getElementById('exportHistoryList'); + if (!listContainer) return; + + if (!history || history.length === 0) { + listContainer.innerHTML = '