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

67
Views
Stream MongoDB Grid-FS File As Input For fluent-ffmpeg Transcode Process

I am trying to compress/transcode a video file that is saved in my MongoDB database, but I am not sure how I can add it as an input stream into the ffmpeg transcoding process.

Any ideas?

async function transcodeVideo(_id) {
  gfs.collection("originalVideos");

  const video = await gfs.files.findOne({ _id: ObjectId(_id) }); //this is used for other things not shown in this example.

  const gridfsBucket = new mongoose.mongo.GridFSBucket(connection.db, {
    bucketName: "originalVideos",
  });

  const downloadStream = gridfsBucket.openDownloadStream(video._id);

  return new Promise((resolve, reject) => {
    const command = ffmpeg()
      .input(downloadStream)
      .inputFormat("mp4")
      .setFfprobePath(pathToFfprobe.path)
      .setFfmpegPath(pathToFfmpeg)
      .videoCodec("libx264")
      .audioCodec("libmp3lame")
      .size("720x?")
      .on("error", (err) => {
        console.log(err);
      })
      .on("progress", (progress) => {
      })
      .on("end", () => {
      })
      .save("./video.mp4");
  });

enter image description here

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!