web: use metadata when processing media locally
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { CobaltFileMetadataKeys, type CobaltFileMetadata } from "$lib/types/api";
|
||||
|
||||
export const formatFileSize = (size: number | undefined) => {
|
||||
size ||= 0;
|
||||
|
||||
@@ -12,3 +14,15 @@ export const formatFileSize = (size: number | undefined) => {
|
||||
const unit = units[units.length - 1] + "B";
|
||||
return `${roundedSize} ${unit}`;
|
||||
}
|
||||
|
||||
export const ffmpegMetadataArgs = (metadata: CobaltFileMetadata) =>
|
||||
Object.entries(metadata).flatMap(([name, value]) => {
|
||||
if (CobaltFileMetadataKeys.includes(name) && typeof value === "string") {
|
||||
return [
|
||||
'-metadata',
|
||||
// eslint-disable-next-line no-control-regex
|
||||
`${name}=${value.replace(/[\u0000-\u0009]/g, "")}`
|
||||
]
|
||||
}
|
||||
return [];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user