Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

336
Views
How can I use ffmpeg module to trim youtube video?

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);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!