mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Add presets to FFmpeg in menu
This commit is contained in:
@ -36,6 +36,7 @@ const defaultConfig = {
|
||||
enabled: false,
|
||||
ffmpegArgs: [], // e.g. ["-b:a", "192k"] for an audio bitrate of 192kb/s
|
||||
downloadFolder: undefined, // Custom download folder (absolute path)
|
||||
preset: "mp3",
|
||||
},
|
||||
"last-fm": {
|
||||
enabled: false,
|
||||
|
||||
@ -8,7 +8,7 @@ const chokidar = require('chokidar');
|
||||
|
||||
const { setOptions } = require("../../config/plugins");
|
||||
const { sendError } = require("./back");
|
||||
const { defaultMenuDownloadLabel, getFolder } = require("./utils");
|
||||
const { defaultMenuDownloadLabel, getFolder, presets } = require("./utils");
|
||||
|
||||
let downloadLabel = defaultMenuDownloadLabel;
|
||||
let playingPlaylistId = undefined;
|
||||
@ -109,5 +109,17 @@ module.exports = (win, options) => {
|
||||
} // else = user pressed cancel
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Presets",
|
||||
submenu: Object.keys(presets).map((preset) => ({
|
||||
label: preset,
|
||||
type: "radio",
|
||||
click: () => {
|
||||
options.preset = preset;
|
||||
setOptions("downloader", options);
|
||||
},
|
||||
checked: options.preset === preset || presets[preset] === undefined,
|
||||
})),
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
@ -28,3 +28,12 @@ module.exports.cropMaxWidth = (image) => {
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
// Presets for FFmpeg
|
||||
module.exports.presets = {
|
||||
"None (defaults to mp3)": undefined,
|
||||
opus: {
|
||||
extension: "opus",
|
||||
ffmpegArgs: ["-acodec", "libopus"],
|
||||
},
|
||||
};
|
||||
|
||||
@ -15,7 +15,7 @@ const ytdl = require("ytdl-core");
|
||||
|
||||
const { triggerAction, triggerActionSync } = require("../utils");
|
||||
const { ACTIONS, CHANNEL } = require("./actions.js");
|
||||
const { urlToJPG } = require("./utils");
|
||||
const { presets, urlToJPG } = require("./utils");
|
||||
const { cleanupName } = require("../../providers/song-info");
|
||||
|
||||
const { createFFmpeg } = FFmpeg;
|
||||
@ -113,8 +113,9 @@ const toMP3 = async (
|
||||
existingMetadata = undefined,
|
||||
subfolder = ""
|
||||
) => {
|
||||
const convertOptions = { ...presets[options.preset], ...options };
|
||||
const safeVideoName = randomBytes(32).toString("hex");
|
||||
const extension = options.extension || "mp3";
|
||||
const extension = convertOptions.extension || "mp3";
|
||||
const releaseFFmpegMutex = await ffmpegMutex.acquire();
|
||||
|
||||
try {
|
||||
@ -132,7 +133,7 @@ const toMP3 = async (
|
||||
"-i",
|
||||
safeVideoName,
|
||||
...getFFmpegMetadataArgs(metadata),
|
||||
...(options.ffmpegArgs || []),
|
||||
...(convertOptions.ffmpegArgs || []),
|
||||
safeVideoName + "." + extension
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user