Guys I just want to trim a video like, I want user to choose the start and end time of the video and accordingly I want to download only that portion of the video and I'm already using ytdl node js module for that
Here is my code, please tell me how can I use ffmpeg in this case, I'm confused
// Code owner: Elderny1 on telegram
const express = require("express");
const ytdl = require("ytdl-core");
const ffmpeg = require("fluent-ffmpeg");
const app = express();
const port = process.env.PORT || 80
// opens the url in the default browser
let info = [];
app.use(express.json());
app.use(express.static("public"));
app.get("/", (req, res) => {
res.sendFile(__dirname + "public/index.html");
});
app.get("/videoInfo", async (req, res) => {
const videoURL = req.query.videoURL;
info = await ytdl.getInfo(videoURL);
res.status(200).json(info);
});
app.get("/download", (req, res) => {
const videoURL = req.query.videoURL;
const itag = req.query.itag;
const vid_title = info.videoDetails.title;
let filesize = "";
for (i = 0; i < info.formats.length; i++) {
if (info.formats[i].itag == itag) {
filesize = info.formats[i].contentLength;
break;
}
}
let filenamee = "";
for (i = 0; i < info.formats.length; i++) {
if (info.formats[i].itag == itag) {
filenamee = vid_title + "." + info.formats[i].container;
break;
}
}
if (filesize != undefined) {
res.header({
"Content-Disposition": 'attachment; filename="' + filenamee + '"',
"Content-Length": filesize
});
} else {
res.header("Content-Disposition", 'attachment; filename="' + filenamee + '"');
}
ytdl(videoURL, {
filter: (format) => format.itag == itag,
}).pipe(res);
});
app.listen(port);