fix audio metadata

This commit is contained in:
Mylloon 2024-09-19 01:29:17 +02:00
parent 21050bb0b7
commit dc190ab807
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 12 additions and 5 deletions

View file

@ -216,7 +216,7 @@ app.whenReady().then(() => {
};
/** Move metadata at the begenning of the file */
const moveMetadata = async (file: string) => {
const moveMetadata = async (file: string, nbTracks: number) => {
const finalFile = getNewFilename(file, "Broadcastable - ");
// Optimize for streaming
@ -225,6 +225,7 @@ app.whenReady().then(() => {
-i "${file}" \
-map 0 -codec copy \
${shareOpt} \
${nbTracks === 3 ? metadataAudio : ""} \
"${finalFile}"`
).catch((e) => registerError(win, e));
@ -245,7 +246,9 @@ app.whenReady().then(() => {
(_, file: string, bitrate: number, audioTracks: number[]) =>
reduceSize(file, bitrate, audioTracks)
);
ipcMain.handle("moveMetadata", (_, file: string) => moveMetadata(file));
ipcMain.handle("moveMetadata", (_, file: string, nbTracks: number) =>
moveMetadata(file, nbTracks)
);
ipcMain.handle("exit", () => (error ? {} : app.quit()));
ipcMain.handle("confirmation", (_, text: string) => confirmation(text));
});

View file

@ -15,7 +15,8 @@ contextBridge.exposeInMainWorld("internals", {
mergeAudio: (file: string) => ipcRenderer.invoke("mergeAudio", file),
reduceSize: (file: string, bitrate: number, audioTracks: number[]) =>
ipcRenderer.invoke("reduceSize", file, bitrate, audioTracks),
moveMetadata: (file: string) => ipcRenderer.invoke("moveMetadata", file),
moveMetadata: (file: string, nbTracks: number) =>
ipcRenderer.invoke("moveMetadata", file, nbTracks),
exit: () => ipcRenderer.invoke("exit"),
confirmation: (text: string) => ipcRenderer.invoke("confirmation", text),
});

View file

@ -18,7 +18,7 @@ let internals: {
bitrate: number,
audioTracks: number[]
) => Promise<string>;
moveMetadata: (file: string) => Promise<string>;
moveMetadata: (file: string, nbTracks: number) => Promise<string>;
confirmation: (text: string) => Promise<void>;
};
@ -141,7 +141,10 @@ const main = async () => {
updateMessage(`\nPréparation pour le partage...`, true, Mode.Append);
// Move the metadata to make it playable before everything is downloaded
finalTitle = await internals.moveMetadata(newFile.title);
finalTitle = await internals.moveMetadata(
newFile.title,
newFile.audioTracks.length
);
}
// Append title to the list of processed files