Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

337
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda