Skip to content

fix(audio): map webm and mp4 container mime types to audio extensions#1030

Open
mrmorgan-i wants to merge 1 commit into
prism-php:mainfrom
mrmorgan-i:fix/audio-container-mime-extensions
Open

fix(audio): map webm and mp4 container mime types to audio extensions#1030
mrmorgan-i wants to merge 1 commit into
prism-php:mainfrom
mrmorgan-i:fix/audio-container-mime-extensions

Conversation

@mrmorgan-i

Copy link
Copy Markdown

Description

finfo reports browser MediaRecorder output as video/webm, since WebM is a container format. That isn't in GeneratesAudioFilename's match list, so it falls through to default => 'mp3' and the file gets uploaded as audio.mp3 with WebM bytes inside it. OpenAI fails to parse it with:

OpenAI Error [400]: invalid_request_error - Audio file might be corrupted or unsupported

Same thing happens with video/mp4, which is what Safari's MediaRecorder produces.

This adds the container types to the existing match list. The default => 'mp3' fallback is unchanged, along with the three tests covering it.

Related to #981. That issue covers the audio/x-wav alias, and #1001 handles it at the Media layer, which makes sense for aliases that are for sure audio. video/webm is different because it's a truthful mime type, and normalizing it in Media would break genuine video input such as Gemini's. So this only touches the audio filename helper, and the two changes shouldn't conflict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant