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

View file

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

View file

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