if no compression is needed, optimize for streaming
This commit is contained in:
parent
d4bb073218
commit
0399080d6e
3 changed files with 29 additions and 3 deletions
25
src/main.ts
25
src/main.ts
|
@ -26,7 +26,7 @@ const metadataAudio = `-metadata:s:a:0 title="System sounds and microphone" \
|
||||||
-metadata:s:a:1 title="System sounds" \
|
-metadata:s:a:1 title="System sounds" \
|
||||||
-metadata:s:a:2 title="Microphone"`;
|
-metadata:s:a:2 title="Microphone"`;
|
||||||
|
|
||||||
const extraArgs = "-movflags +faststart";
|
const shareOpt = "-movflags +faststart";
|
||||||
|
|
||||||
/** Register a new error */
|
/** Register a new error */
|
||||||
const registerError = (win: BrowserWindow, err: string) => {
|
const registerError = (win: BrowserWindow, err: string) => {
|
||||||
|
@ -109,7 +109,6 @@ app.whenReady().then(() => {
|
||||||
-map 0 -map 1:a -c:v copy \
|
-map 0 -map 1:a -c:v copy \
|
||||||
-disposition:a 0 -disposition:a:0 default \
|
-disposition:a 0 -disposition:a:0 default \
|
||||||
${metadataAudio} \
|
${metadataAudio} \
|
||||||
${extraArgs} \
|
|
||||||
"${outFile}"`
|
"${outFile}"`
|
||||||
).catch((e) => registerError(win, e));
|
).catch((e) => registerError(win, e));
|
||||||
|
|
||||||
|
@ -185,7 +184,7 @@ app.whenReady().then(() => {
|
||||||
-c:v ${codec} -b:v ${videoBitrate}k -pass 2 -c:a copy \
|
-c:v ${codec} -b:v ${videoBitrate}k -pass 2 -c:a copy \
|
||||||
${mappingTracks} -f mp4 \
|
${mappingTracks} -f mp4 \
|
||||||
${metadataAudio} \
|
${metadataAudio} \
|
||||||
${extraArgs} \
|
${shareOpt} \
|
||||||
"${finalFile}"`
|
"${finalFile}"`
|
||||||
).catch((e) => registerError(win, e));
|
).catch((e) => registerError(win, e));
|
||||||
|
|
||||||
|
@ -198,6 +197,25 @@ app.whenReady().then(() => {
|
||||||
return finalFile;
|
return finalFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Move metadata at the begenning of the file */
|
||||||
|
const moveMetadata = async (file: string) => {
|
||||||
|
const finalFile = getNewFilename(file, "Shareable - ");
|
||||||
|
|
||||||
|
// Optimize for streaming
|
||||||
|
await execute(
|
||||||
|
`"${ffmpegPath}" -y \
|
||||||
|
-i "${file}" \
|
||||||
|
-map 0 -codec copy \
|
||||||
|
${shareOpt} \
|
||||||
|
"${finalFile}"`
|
||||||
|
).catch((e) => registerError(win, e));
|
||||||
|
|
||||||
|
// Delete the old video file
|
||||||
|
deleteFile(file);
|
||||||
|
|
||||||
|
return finalFile;
|
||||||
|
};
|
||||||
|
|
||||||
/* Context bridge */
|
/* Context bridge */
|
||||||
ipcMain.handle("argv", () => process.argv);
|
ipcMain.handle("argv", () => process.argv);
|
||||||
ipcMain.handle("allowedExtensions", () => moviesFilter);
|
ipcMain.handle("allowedExtensions", () => moviesFilter);
|
||||||
|
@ -209,6 +227,7 @@ app.whenReady().then(() => {
|
||||||
(_, file: string, bitrate: number, nbTracks: number) =>
|
(_, file: string, bitrate: number, nbTracks: number) =>
|
||||||
reduceSize(file, bitrate, nbTracks)
|
reduceSize(file, bitrate, nbTracks)
|
||||||
);
|
);
|
||||||
|
ipcMain.handle("moveMetadata", (_, file: string) => moveMetadata(file));
|
||||||
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));
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,6 +15,7 @@ contextBridge.exposeInMainWorld("internals", {
|
||||||
mergeAudio: (file: string) => ipcRenderer.invoke("mergeAudio", file),
|
mergeAudio: (file: string) => ipcRenderer.invoke("mergeAudio", file),
|
||||||
reduceSize: (file: string, bitrate: number, nbTracks: number) =>
|
reduceSize: (file: string, bitrate: number, nbTracks: number) =>
|
||||||
ipcRenderer.invoke("reduceSize", file, bitrate, nbTracks),
|
ipcRenderer.invoke("reduceSize", file, bitrate, nbTracks),
|
||||||
|
moveMetadata: (file: string) => ipcRenderer.invoke("moveMetadata", file),
|
||||||
exit: () => ipcRenderer.invoke("exit"),
|
exit: () => ipcRenderer.invoke("exit"),
|
||||||
confirmation: (text: string) => ipcRenderer.invoke("confirmation", text),
|
confirmation: (text: string) => ipcRenderer.invoke("confirmation", text),
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,6 +18,7 @@ let internals: {
|
||||||
bitrate: number,
|
bitrate: number,
|
||||||
nbTracks: number
|
nbTracks: number
|
||||||
) => Promise<string>;
|
) => Promise<string>;
|
||||||
|
moveMetadata: (file: string) => Promise<string>;
|
||||||
confirmation: (text: string) => Promise<void>;
|
confirmation: (text: string) => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -133,6 +134,11 @@ const main = async () => {
|
||||||
bitrate,
|
bitrate,
|
||||||
newFile.nbTracks
|
newFile.nbTracks
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append title to the list of processed files
|
// Append title to the list of processed files
|
||||||
|
|
Loading…
Reference in a new issue