From 640582df336dbc82bdb57552151ea3024967621e Mon Sep 17 00:00:00 2001 From: Mike Johnston Date: Mon, 9 Feb 2026 21:53:52 -0500 Subject: [PATCH] previews and back to edit button --- app.py | 14 ++++++++++++++ templates/index.html | 38 ++++++++++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 09bda63..6cb66e6 100644 --- a/app.py +++ b/app.py @@ -211,6 +211,20 @@ def download_video(file_id): except Exception as e: return jsonify({'error': str(e)}), 500 +@app.route('/preview/') +def preview_video(file_id): + """Serve processed video for inline preview""" + try: + output_filename = f"{file_id}_processed.mp4" + output_path = os.path.join(app.config['OUTPUT_FOLDER'], output_filename) + + if not os.path.exists(output_path): + return jsonify({'error': 'File not found'}), 404 + + return send_file(output_path, mimetype='video/mp4') + except Exception as e: + return jsonify({'error': str(e)}), 500 + @app.route('/cleanup/', methods=['DELETE']) def cleanup_files(file_id): """Clean up uploaded and processed files""" diff --git a/templates/index.html b/templates/index.html index 02506ba..37ae070 100644 --- a/templates/index.html +++ b/templates/index.html @@ -596,7 +596,7 @@ Quality: High CRF: 23 - +

💡 Lower CRF = Better quality, larger file. Higher CRF = More compressed, smaller file.

@@ -606,7 +606,7 @@ - + @@ -637,8 +637,16 @@ @@ -987,11 +995,12 @@ // Update quality label let qualityLabel = 'Balanced'; - if (compressionQuality <= 19) qualityLabel = 'Best Quality'; - else if (compressionQuality <= 22) qualityLabel = 'High'; + if (compressionQuality <= 19) qualityLabel = 'Overkill'; + else if (compressionQuality <= 22) qualityLabel = 'Quality'; else if (compressionQuality <= 25) qualityLabel = 'Balanced'; - else if (compressionQuality <= 28) qualityLabel = 'Low'; - else qualityLabel = 'Smallest File'; + else if (compressionQuality <= 28) qualityLabel = 'Compressed'; + else if (compressionQuality <= 32) qualityLabel = 'Small File'; + else qualityLabel = 'Dog 💩'; qualityValueDisplay.textContent = qualityLabel; } @@ -1068,6 +1077,10 @@ throw new Error(data.error || 'Processing failed'); } + // Load processed video preview + const processedVideoPreview = document.getElementById('processed-video-preview'); + processedVideoPreview.src = `/preview/${currentFileId}`; + // Show download section document.getElementById('edit-section').classList.add('hidden'); document.getElementById('download-section').classList.remove('hidden'); @@ -1086,9 +1099,22 @@ window.location.href = `/download/${currentFileId}`; }); + // Back to edit button + document.getElementById('back-to-edit-btn').addEventListener('click', backToEdit); + // Reset buttons document.getElementById('reset-btn').addEventListener('click', resetApp); document.getElementById('new-video-btn').addEventListener('click', resetApp); + + function backToEdit() { + // Go back to edit section without resetting values + document.getElementById('download-section').classList.add('hidden'); + document.getElementById('edit-section').classList.remove('hidden'); + + // Clear the processed video preview to free memory + const processedVideoPreview = document.getElementById('processed-video-preview'); + processedVideoPreview.src = ''; + } async function resetApp() { if (currentFileId) {