diff --git a/editor.py b/editor.py index 4805861..874fe41 100644 --- a/editor.py +++ b/editor.py @@ -241,12 +241,16 @@ def create_finished(filename, start, end): result = subprocess.run( [ "ffmpeg", "-hide_banner", "-loglevel", "warning", "-y", - "-i", str(source), + "-fflags", "+genpts", "-ss", f"{start:.3f}", + "-i", str(source), "-t", f"{end - start:.3f}", + "-map", "0:a:0", + "-vn", "-sn", "-dn", "-af", "loudnorm=I=-16:TP=-1.5:LRA=11", "-c:a", "libmp3lame", "-b:a", "128k", + "-avoid_negative_ts", "make_zero", str(temp), ], capture_output=True, text=True, timeout=1800, @@ -676,8 +680,15 @@ async function trim() { msg('Aufnahme wird geschnitten …',true); try { const r=await fetch('/api/edit', {method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({filename,start,end})}); - const d=await r.json(); - if(!r.ok || !d.success) throw new Error(d.error || 'Fehler beim Schneiden'); + const contentType = r.headers.get('content-type') || ''; + let d; + if (contentType.includes('application/json')) { + d = await r.json(); + } else { + const text = await r.text(); + throw new Error(`Serverfehler HTTP ${r.status}: ${text.slice(0, 200)}`); + } + if(!r.ok || !d.success) throw new Error(d.error || `Fehler beim Schneiden (HTTP ${r.status})`); msg('Fertige Aufnahme erfolgreich erstellt.',true); setTimeout(()=>location.reload(),700); } catch(e) { msg(e.message,false); btn.disabled=false; }