upload feedbackto server

This commit is contained in:
DigiServer Developer
2025-09-08 14:04:13 +03:00
parent 505c8e268c
commit a5ef5749b1
8 changed files with 1567 additions and 51 deletions

View File

@@ -1,4 +1,4 @@
import os
import os
import subprocess
from flask import Flask
from werkzeug.utils import secure_filename
@@ -56,8 +56,39 @@ def convert_video(input_file, output_folder):
return input_file
def convert_video_and_update_playlist(app, file_path, original_filename, target_type, target_id, duration):
print(f"Video conversion skipped for: {file_path}")
return None
import shutil
import tempfile
print(f"Starting video normalization for: {file_path}")
# Only process .mp4 files
if not file_path.lower().endswith('.mp4'):
print(f"Skipping non-mp4 file: {file_path}")
return None
# Prepare temp output file
temp_dir = tempfile.gettempdir()
temp_output = os.path.join(temp_dir, f"normalized_{os.path.basename(file_path)}")
ffmpeg_cmd = [
'ffmpeg', '-y', '-i', file_path,
'-c:v', 'libx264', '-profile:v', 'main',
# Bitrate is not forced, so we allow lower bitrates
'-vf', 'scale=1920:1080,fps=29.97',
'-c:a', 'copy',
temp_output
]
print(f"Running ffmpeg: {' '.join(ffmpeg_cmd)}")
try:
result = subprocess.run(ffmpeg_cmd, capture_output=True, text=True, timeout=1800)
if result.returncode != 0:
print(f"ffmpeg error: {result.stderr}")
return None
# Replace original file with normalized one
shutil.move(temp_output, file_path)
print(f"Video normalized and replaced: {file_path}")
except Exception as e:
print(f"Error during video normalization: {e}")
return None
# No need to update playlist, as filename remains the same
return True
# PDF conversion functions
def convert_pdf_to_images(pdf_file, output_folder, delete_pdf=True, dpi=300):