From a70701f2600af3a1bf863d709d89d9592a28d77b Mon Sep 17 00:00:00 2001 From: Jonathan Schuster Date: Wed, 29 Apr 2026 20:56:51 +0200 Subject: [PATCH] fix: cut metadata, J/K cut fields, screen reader section announcements Cut metadata: WAV and FLAC are now re-encoded (pcm_s16le / flac) instead of stream-copied, so the container header is always rewritten with the correct duration. Lossy formats keep -c copy. J/K shortcuts: now also update the cut panel start/end fields to match the section they landed on, and announce the section aloud. Screen reader: added aria-live polite region; chip clicks and J/K announce 'Section N of M: start to end'; boundary presses announce 'Beginning of sections' or 'End of sections'. Pre-roll: configurable 'Pre-roll' seconds input in the controls bar (default 3 s); all section seeks subtract the pre-roll from the target position so the listener hears context before the loud section begins. --- web.py | 88 +++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 20 deletions(-) diff --git a/web.py b/web.py index 73b7947..9b8db92 100644 --- a/web.py +++ b/web.py @@ -497,12 +497,19 @@ class _Handler(BaseHTTPRequestHandler): ext = path.suffix.lower() out_name = f'{path.stem}_cut_{int(start)}s-{int(end)}s{ext}' + # For lossless formats, re-encode (not copy) so the container header + # is rewritten with the correct duration/size. For lossy formats, + # copy is fine — the audio stops at the right frame regardless. + _lossless = {'.wav': ['-c:a', 'pcm_s16le'], '.flac': ['-c:a', 'flac']} + codec_args = _lossless.get(ext, ['-c', 'copy']) + fd, tmp_path = tempfile.mkstemp(suffix=ext) os.close(fd) try: - cmd = ['ffmpeg', '-y', '-i', str(path), + cmd = ['ffmpeg', '-y', + '-i', str(path), '-ss', str(start), '-to', str(end), - '-c', 'copy', tmp_path] + '-vn'] + codec_args + [tmp_path] result = subprocess.run(cmd, capture_output=True, timeout=120) if result.returncode != 0: err = result.stderr.decode('utf-8', errors='replace')[-400:] @@ -663,6 +670,7 @@ button.cut:hover:not(:disabled){background:#1e3a8a} +

ISR Archive

@@ -675,6 +683,10 @@ button.cut:hover:not(:disabled){background:#1e3a8a} RMS 0–1 · sections above this value are marked loud + + + seconds to rewind before section start