Implement convert with audio #94

pull/276/head
Mikael Finstad 6 years ago
parent 085b72591e
commit 9ed3b4a40e

@ -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,
];

@ -22,7 +22,6 @@ function createWindow() {
webPreferences: {
nodeIntegration: true,
},
});
mainWindow.loadFile(isDev ? 'index.html' : 'build/index.html');

@ -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() {

@ -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);

Loading…
Cancel
Save