web/workers/ffmpeg: proper error code for missing audio channel error
Some checks are pending
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
Run tests / check lockfile correctness (push) Waiting to run
Run tests / web sanity check (push) Waiting to run
Run tests / api sanity check (push) Waiting to run

This commit is contained in:
wukko 2025-06-14 17:24:47 +06:00
parent 5ea170a5ac
commit 507fab847b
No known key found for this signature in database
GPG Key ID: 3E30B3F26C7B4AA2
2 changed files with 10 additions and 1 deletions

View File

@ -15,5 +15,6 @@
"ffmpeg.no_input_type": "the file's type isn't supported",
"ffmpeg.crashed": "ffmpeg worker crashed, see console for details",
"ffmpeg.no_render": "ffmpeg render is empty, something very odd happened",
"ffmpeg.no_args": "ffmpeg worker didn't get required arguments"
"ffmpeg.no_args": "ffmpeg worker didn't get required arguments",
"ffmpeg.no_audio_channel": "this video has no audio track, nothing to do"
}

View File

@ -64,6 +64,14 @@ const ffmpeg = async (variant: string, files: File[], args: string[], output: Fi
return error("queue.ffmpeg.no_input_format");
}
// handle the edge case when a video doesn't have an audio track
// but user still tries to extract it
if (files.length === 1 && file_info.streams?.length === 1) {
if (output.type?.startsWith("audio") && file_info.streams[0].codec_type !== "audio") {
return error("queue.ffmpeg.no_audio_channel");
}
}
self.postMessage({
cobaltFFmpegWorker: {
progress: {