Skip to content

Commit 4560e5a

Browse files
committed
fix(media): drop weba from the output allowlist
FFmpeg's muxer is named webm and refuses a .weba output ('Error initializing the muxer'), so allowlisting the extension only converted a clear 'unsupported format' rejection into a confusing encode-time failure. weba was added in this PR because it appears in the input MIME map, but naming an input file and naming an output muxer are different questions. extract_audio takes webm.
1 parent 79d78e5 commit 4560e5a

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

apps/sim/lib/media/ffmpeg.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,18 @@ describe('runFfmpegOperation output format validation', () => {
5757
(e: Error) => e
5858
)
5959

60-
for (const format of ['mp4', 'mov', 'webm', 'mp3', 'wav', 'gif', 'webp', 'weba']) {
60+
for (const format of ['mp4', 'mov', 'webm', 'mp3', 'wav', 'gif', 'webp']) {
6161
expect(error.message).toContain(format)
6262
}
6363
})
64+
65+
it('rejects weba, which FFmpeg has no muxer for', async () => {
66+
// The extension appears in the input MIME map, but `ffmpeg out.weba` fails
67+
// with "Error initializing the muxer" — webm is the muxer's real name.
68+
await expect(runFfmpegOperation('convert', [mediaFile()], { format: 'weba' })).rejects.toThrow(
69+
'Unsupported output format'
70+
)
71+
})
6472
})
6573

6674
describe('runFfmpegOperation scale bounds', () => {

apps/sim/lib/media/ffmpeg.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ const EXT_TO_MIME: Record<string, string> = {
189189
flac: 'audio/flac',
190190
aac: 'audio/aac',
191191
opus: 'audio/opus',
192-
weba: 'audio/webm',
193192
png: 'image/png',
194193
jpg: 'image/jpeg',
195194
jpeg: 'image/jpeg',
@@ -216,16 +215,20 @@ const OUTPUT_EXTS = new Set([
216215
'flac',
217216
'aac',
218217
'opus',
219-
'weba',
220218
'png',
221219
'jpg',
222220
'jpeg',
223221
'gif',
224222
'webp',
225223
])
226224

227-
/** extract_audio can only name an audio container; the rest would silently produce nothing useful. */
228-
const AUDIO_EXTS = new Set(['mp3', 'm4a', 'wav', 'ogg', 'flac', 'aac', 'opus', 'weba'])
225+
/**
226+
* extract_audio can only name an audio container; the rest would silently
227+
* produce nothing useful. `webm`, not `weba` — FFmpeg's muxer is named webm and
228+
* it refuses a .weba output, so allowlisting that extension would only produce
229+
* a muxer error at encode time.
230+
*/
231+
const AUDIO_EXTS = new Set(['mp3', 'm4a', 'wav', 'ogg', 'flac', 'aac', 'opus', 'webm'])
229232

230233
/**
231234
* Temp-file names are built as `${prefix}.${ext}` and joined against the temp

0 commit comments

Comments
 (0)