Skip to content

Commit 1e7d967

Browse files
author
aandrew-me
committed
Refactoring fix
1 parent 118dd31 commit 1e7d967

File tree

5 files changed

+47
-31
lines changed

5 files changed

+47
-31
lines changed

assets/css/index.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ body::-webkit-scrollbar-thumb {
733733

734734
.container {
735735
max-width: 800px;
736-
margin: 0 auto 10px auto;
736+
margin: 30px auto 10px auto;
737737
background: var(--box-main);
738738
padding: 30px;
739739
border-radius: 8px;
@@ -778,7 +778,7 @@ body::-webkit-scrollbar-thumb {
778778
}
779779

780780
#output-folder-box {
781-
background-color: var(--item-bg);
781+
background-color: var(--box-toggle);
782782
margin-bottom: 12px;
783783
padding: 15px;
784784
border-radius: 8px;

html/compressor.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
</head>
1010

1111
<body id="compressor_body">
12+
<!-- Popup message -->
13+
<span id="popupText">Text copied</span>
14+
1215
<!-- Menu icon -->
1316
<img src="../assets/images/menu.png" alt="menu" id="menuIcon">
1417

@@ -48,7 +51,7 @@ <h1 id="compressor-header">Video Compressor</h1>
4851
<option value="unchanged">Unchanged</option>
4952
<option value="mp4">mp4</option>
5053
<option value="mkv">mkv</option>
51-
<option value="webm">webm</option>
54+
<!-- <option value="webm">webm</option> -->
5255
</select>
5356
</div>
5457

@@ -135,7 +138,7 @@ <h1 id="compressor-header">Video Compressor</h1>
135138
<option value="copy">Unchanged</option>
136139
<option value="aac">aac</option>
137140
<option value="mp3">mp3</option>
138-
<option value="opus">opus</option>
141+
<!-- <option value="libopus">opus</option> -->
139142
</select>
140143
</div>
141144

src/common.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ getId("menuIcon").addEventListener("click", () => {
2121
getId("menu").style.display = "none";
2222
clearInterval(fade);
2323
} else {
24+
opacity -= 0.1;
2425
getId("menu").style.opacity = opacity.toFixed(3).toString();
2526
count++;
2627
}
@@ -31,7 +32,7 @@ getId("menuIcon").addEventListener("click", () => {
3132

3233
setTimeout(() => {
3334
getId("menu").style.display = "flex";
34-
getId("menu").style.opacity = 1;
35+
getId("menu").style.opacity = "1";
3536
}, 150);
3637
}
3738
});

src/compressor.js

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ getId("menuIcon").addEventListener("click", () => {
3737
let ffmpeg;
3838
if (os.platform() === "win32") {
3939
ffmpeg = `"${__dirname}\\..\\ffmpeg.exe"`;
40-
} else {
40+
} else if (os.platform() === "freebsd") {
41+
try {
42+
ffmpeg = cp.execSync("which ffmpeg").toString("utf8").split("\n")[0].trim();
43+
} catch (error) {
44+
console.log(error)
45+
showPopup("No ffmpeg found in PATH.");
46+
}
47+
}
48+
else {
4149
ffmpeg = `"${__dirname}/../ffmpeg"`;
4250
}
4351

@@ -304,6 +312,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
304312
"libx264",
305313
"-preset",
306314
settings.speed,
315+
"-vf", "format=yuv420p",
307316
"-crf",
308317
parseInt(settings.videoQuality).toString()
309318
);
@@ -312,6 +321,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
312321
args.push(
313322
"-c:v",
314323
"libx265",
324+
"-vf", "format=yuv420p",
315325
"-preset",
316326
settings.speed,
317327
"-crf",
@@ -323,6 +333,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
323333
args.push(
324334
"-c:v",
325335
"h264_qsv",
336+
"-vf", "format=yuv420p",
326337
"-preset",
327338
settings.speed,
328339
"-global_quality",
@@ -359,6 +370,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
359370
args.push(
360371
"-c:v",
361372
"h264_nvenc",
373+
"-vf", "format=yuv420p",
362374
"-preset",
363375
getNvencPreset(settings.speed),
364376
"-rc",
@@ -380,6 +392,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
380392
args.push(
381393
"-c:v",
382394
"hevc_amf",
395+
"-vf", "format=yuv420p",
383396
"-quality",
384397
amf_hevc_quality,
385398
"-rc",
@@ -402,6 +415,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
402415
args.push(
403416
"-c:v",
404417
"h264_amf",
418+
"-vf", "format=yuv420p",
405419
"-quality",
406420
amf_quality,
407421
"-rc",
@@ -417,6 +431,7 @@ function buildFFmpegCommand(file, settings, outputPath) {
417431
case "videotoolbox":
418432
args.push(
419433
"-c:v",
434+
"-vf", "format=yuv420p",
420435
"h264_videotoolbox",
421436
"-q:v",
422437
parseInt(settings.videoQuality).toString()
@@ -426,8 +441,6 @@ function buildFFmpegCommand(file, settings, outputPath) {
426441

427442
// args.push("-vf", "scale=trunc(iw*1/2)*2:trunc(ih*1/2)*2,format=yuv420p");
428443

429-
args.push("-vf", "format=yuv420p");
430-
431444
args.push("-c:a", settings.audioFormat, `"${outputPath}"`);
432445

433446
return `${ffmpeg} ${args.join(" ")}`;
@@ -499,7 +512,7 @@ function createProgressItem(filename, status, data, itemId) {
499512
<div class="filename">${visibleFilename}</div>
500513
<div id="${itemId + "_prog"}" class="itemProgress">${data}</div>
501514
`;
502-
statusElement.prepend(newStatus);
515+
statusElement.append(newStatus);
503516
}
504517

505518
/**
@@ -528,21 +541,6 @@ function timeToSeconds(timeStr) {
528541
return hh * 3600 + mm * 60 + ss;
529542
}
530543

531-
// Menu
532-
getId("preferenceWin").addEventListener("click", () => {
533-
closeMenu();
534-
ipcRenderer.send("load-page", __dirname + "/preferences.html");
535-
});
536-
537-
getId("aboutWin").addEventListener("click", () => {
538-
closeMenu();
539-
ipcRenderer.send("load-page", __dirname + "/about.html");
540-
});
541-
getId("homeWin").addEventListener("click", () => {
542-
closeMenu();
543-
ipcRenderer.send("load-win", __dirname + "/index.html");
544-
});
545-
546544
getId("themeToggle").addEventListener("change", () => {
547545
document.documentElement.setAttribute("theme", getId("themeToggle").value);
548546
localStorage.setItem("theme", getId("themeToggle").value);
@@ -591,19 +589,33 @@ function closeMenu() {
591589
// Menu
592590
getId("preferenceWin").addEventListener("click", () => {
593591
closeMenu();
592+
menuIsOpen = false;
594593
ipcRenderer.send("load-page", __dirname + "/preferences.html");
595594
});
596595

597596
getId("playlistWin").addEventListener("click", () => {
598597
closeMenu();
598+
menuIsOpen = false;
599599
ipcRenderer.send("load-win", __dirname + "/playlist.html");
600600
});
601601

602602
getId("aboutWin").addEventListener("click", () => {
603603
closeMenu();
604+
menuIsOpen = false;
604605
ipcRenderer.send("load-page", __dirname + "/about.html");
605606
});
606607
getId("homeWin").addEventListener("click", () => {
607608
closeMenu();
609+
menuIsOpen = false;
608610
ipcRenderer.send("load-win", __dirname + "/index.html");
609-
});
611+
});
612+
613+
// Popup message
614+
function showPopup(text) {
615+
console.log("Triggered showpopup");
616+
getId("popupText").textContent = text;
617+
getId("popupText").style.display = "inline-block";
618+
setTimeout(() => {
619+
getId("popupText").style.display = "none";
620+
}, 2200);
621+
}

src/playlist.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,12 @@ function download(type) {
306306
}
307307

308308

309-
getId("finishBtn").addEventListener("click", () => {
310-
controller.abort("user_finished")
311-
try {
312-
process.kill(downloadProcess.ytDlpProcess.pid, 'SIGINT')
313-
} catch (_error) {}
314-
})
309+
// getId("finishBtn").addEventListener("click", () => {
310+
// controller.abort("user_finished")
311+
// try {
312+
// process.kill(downloadProcess.ytDlpProcess.pid, 'SIGINT')
313+
// } catch (_error) {}
314+
// })
315315

316316
downloadProcess.on("ytDlpEvent", (_eventType, eventData) => {
317317
// console.log(eventData);

0 commit comments

Comments
 (0)