mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 19:03:46 +02:00
30 lines
766 B
TypeScript
30 lines
766 B
TypeScript
/*!
|
|
* Copyright (c) 2026-present, Vanilagy and contributors
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
export const buildMatroskaMimeType = (info: {
|
|
isWebM: boolean;
|
|
hasVideo: boolean;
|
|
hasAudio: boolean;
|
|
codecStrings: string[];
|
|
}) => {
|
|
const base = info.hasVideo
|
|
? 'video/'
|
|
: info.hasAudio
|
|
? 'audio/'
|
|
: 'application/';
|
|
|
|
let string = base + (info.isWebM ? 'webm' : 'x-matroska');
|
|
|
|
if (info.codecStrings.length > 0) {
|
|
const uniqueCodecMimeTypes = [...new Set(info.codecStrings.filter(Boolean))];
|
|
string += `; codecs="${uniqueCodecMimeTypes.join(', ')}"`;
|
|
}
|
|
|
|
return string;
|
|
};
|