Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

344
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda