-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YTDL is being blocked when tried to access the youtube video #1312
Comments
try this const youtubedl = require("youtube-dl-exec");
const ffmpeg = require("fluent-ffmpeg");
const path = require("path");
// Set the path to your ffmpeg binary
const ffmpegPath = path.join(process.cwd(), "tmp", "ffmpeg");
ffmpeg.setFfmpegPath(ffmpegPath);
// Replace the URL with the desired YouTube video URL
const videoUrl = "";
async function convertWebMToMP3(inputFilePath) {
const outputFilePath = `output.mp3`;
return new Promise((resolve, reject) => {
ffmpeg(inputFilePath)
.audioBitrate(128)
.toFormat("mp3")
.on("end", () => {
console.log("Conversion finished successfully");
resolve(outputFilePath);
})
.on("error", (err) => {
console.error("Error during conversion:", err);
reject(err);
})
.save(outputFilePath);
});
}
async function downloadAndConvert() {
const webmFilePath = path.join(process.cwd(), "tmp", "output.webm");
try {
// Step 1: Download the audio as WebM
const output = await youtubedl(videoUrl, {
extractAudio: true,
audioFormat: "mp3",
preferFfmpeg: true,
output: webmFilePath,
});
console.log("Download completed:", output);
// Step 2: Convert WebM to MP3
const mp3Path = await convertWebMToMP3(webmFilePath);
console.log("MP3 saved to:", mp3Path);
} catch (err) {
console.error("Error:", err);
}
}
downloadAndConvert(); |
did
did you just use a whole different library |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to access the youtube video and trying to download it for the use of my code and it is forbidding the process
Here's the ERROR
let err = new Miniget.MinigetError(
Status code: ${res.statusCode}
, res.statusCode);^
Can anyone help me out on this?
The text was updated successfully, but these errors were encountered: