Skip to content

The swiss army knife of lossless video/audio editing

Implement convert with audio #94

Mikael Finstad9ed3b4a40eac
diff --git a/src/ffmpeg.js b/src/ffmpeg.js
index c5063009..52d0f7df 100644
--- a/src/ffmpeg.js
+++ b/src/ffmpeg.js
@@ -166,15 +166,17 @@ async function cutMultiple({
return outFiles;
}
-async function html5ify(filePath, outPath, encodeVideo) {
+async function html5ify(filePath, outPath, encodeVideo, encodeAudio) {
console.log('Making HTML5 friendly version', { filePath, outPath, encodeVideo });
const videoArgs = encodeVideo
? ['-vf', 'scale=-2:400,format=yuv420p', '-sws_flags', 'neighbor', '-vcodec', 'libx264', '-profile:v', 'baseline', '-x264opts', 'level=3.0', '-preset:v', 'ultrafast', '-crf', '28']
: ['-vcodec', 'copy'];
+ const audioArgs = encodeAudio ? ['-acodec', 'aac', '-b:a', '96k'] : ['-an'];
+
const ffmpegArgs = [
- '-i', filePath, ...videoArgs, '-an',
+ '-i', filePath, ...videoArgs, ...audioArgs,
'-y', outPath,
];
diff --git a/src/index.js b/src/index.js
index 7d935023..93e6d77d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -22,7 +22,6 @@ function createWindow() {
webPreferences: {
nodeIntegration: true,
},
-
});
mainWindow.loadFile(isDev ? 'index.html' : 'build/index.html');
diff --git a/src/menu.js b/src/menu.js
index 9ed9dad2..971e0565 100644
--- a/src/menu.js
+++ b/src/menu.js
@@ -40,6 +40,12 @@ module.exports = (app, mainWindow, newVersion) => {
mainWindow.webContents.send('html5ify', 'slow');
},
},
+ {
+ label: 'Convert to friendly codec (slowest, audio)',
+ click() {
+ mainWindow.webContents.send('html5ify', 'slow-audio');
+ },
+ },
{
label: 'Extract all streams',
click() {
diff --git a/src/renderer.jsx b/src/renderer.jsx
index bb036531..8a4762ec 100644
--- a/src/renderer.jsx
+++ b/src/renderer.jsx
@@ -490,7 +490,7 @@ const App = memo(() => {
if (html5FriendlyPathRequested) {
setHtml5FriendlyPath(html5FriendlyPathRequested);
} else if (
- !(await checkExistingHtml5FriendlyFile(fp, 'slow') || await checkExistingHtml5FriendlyFile(fp, 'fast'))
+ !(await checkExistingHtml5FriendlyFile(fp, 'slow-audio') || await checkExistingHtml5FriendlyFile(fp, 'slow') || await checkExistingHtml5FriendlyFile(fp, 'fast'))
&& !doesPlayerSupportFile(streams)
) {
await createDummyVideo(fp);
@@ -565,10 +565,11 @@ const App = memo(() => {
try {
setWorking(true);
- if (['fast', 'slow'].includes(speed)) {
+ if (['fast', 'slow', 'slow-audio'].includes(speed)) {
const html5FriendlyPathNew = getHtml5ifiedPath(filePath, speed);
- const encodeVideo = speed === 'slow';
- await ffmpeg.html5ify(filePath, html5FriendlyPathNew, encodeVideo);
+ const encodeVideo = ['slow', 'slow-audio'].includes(speed);
+ const encodeAudio = speed === 'slow-audio';
+ await ffmpeg.html5ify(filePath, html5FriendlyPathNew, encodeVideo, encodeAudio);
load(filePath, html5FriendlyPathNew);
} else {
await createDummyVideo(filePath);