Skip to content

Commit e4ce873

Browse files
committed
web/queue: add audio covers & crop them when needed
1 parent 164ea8a commit e4ce873

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

web/src/lib/task-manager/queue.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,27 @@ const makeAudioArgs = (info: CobaltLocalProcessingResponse) => {
8282
return;
8383
}
8484

85-
const ffargs = [
86-
"-vn",
85+
const ffargs = [];
86+
87+
if (info.audio.cover) {
88+
ffargs.push(
89+
"-map", "0",
90+
"-map", "1",
91+
...(info.audio.cropCover ? [
92+
"-c:v", "mjpeg",
93+
"-vf", "scale=-1:800,crop=800:800",
94+
] : [
95+
"-c:v", "copy",
96+
]),
97+
);
98+
} else {
99+
ffargs.push("-vn");
100+
}
101+
102+
ffargs.push(
87103
...(info.audio.copy ? ["-c:a", "copy"] : ["-b:a", `${info.audio.bitrate}k`]),
88104
...(info.output.metadata ? ffmpegMetadataArgs(info.output.metadata) : [])
89-
];
105+
);
90106

91107
if (info.audio.format === "mp3" && info.audio.bitrate === "8") {
92108
ffargs.push("-ar", "12000");

web/src/lib/types/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ export type CobaltLocalProcessingResponse = {
8080
copy: boolean,
8181
format: string,
8282
bitrate: string,
83+
cover?: boolean,
84+
cropCover?: boolean,
8385
},
8486

8587
isHLS?: boolean,

0 commit comments

Comments
 (0)