Commit f2a1dce8 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Fix the real "can't sync to MPEG frame" cause: mutagen, not ffmpeg

The previous fix (permissive ffmpeg retry on CouldntDecodeError) never
actually applied to this case - confirmed via the full traceback this time
(added logger.exception in the prior commit, which paid off immediately):
the failing file had a .mp3 extension, so it took the "already mp3, just
copy" fast path entirely, skipping ffmpeg. The actual failure was
mutagen.mp3.HeaderNotFoundError inside MP3(mp3_file_path, ID3=ID3) - a
.mp3 extension doesn't guarantee mutagen's strict frame-sync scanner can
parse the content.

Now: if that direct-copy fast path produces something mutagen can't read,
re-encode through the same permissive ffmpeg fallback (which sniffs actual
content, not the extension) and retry once. If even that fails, raises the
same AudioDecodeError as before for a clean user-facing message instead of
a raw mutagen exception.

Added tests/test_audio_processing.py with two real (not mocked) cases:
real WAV audio misnamed as .mp3 (exercises the actual recovery path with
real audio content) and pure random bytes (confirms genuinely unrecoverable
input still fails cleanly via AudioDecodeError, not a raw exception).
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 2cb2e5a1
Pipeline #1041 passed with stage
in 9 minutes and 10 seconds