Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to debug the ffmpeg execution? #107

Open
n0th1ng-else opened this issue Jul 19, 2022 · 2 comments
Open

How to debug the ffmpeg execution? #107

n0th1ng-else opened this issue Jul 19, 2022 · 2 comments

Comments

@n0th1ng-else
Copy link

n0th1ng-else commented Jul 19, 2022

Issue:

I am trying to implement the converter into wav. It works pretty fine for mp3/ogg files. But then I wanted to use the same implementation for mp4 file (ie cut the video, convert it into wav) But the output is always empty.

How do I debug the execution and understand what goes wrong?

Steps to reproduce:

To simplify the process, I first tried the convertation with ffmpeg cli:
./node_modules/ffmpeg-static/ffmpeg -i ~/Downloads/file_97.mp4 -vn -ac 1 -ar 16000 test.wav

it works good ^^

Then in the code, I do almost the same, but do a GET request to download the file rather than read the file from the file system. the result is empty...

import { FFmpeg } from "prism-media";

const getMpegDecoder = (): FFmpeg =>
  new FFmpeg({
    args: [
      "-analyzeduration",
      "0",
      "-loglevel",
      "0",
      "-vn",
      "-ar",
      "16000",
      "-ac",
      "1",
    ],
  });

const getWavBuffer = (fileLink: string): Promise<Buffer> => { // buffer is empty
  logger.info("Converting into wav 💿");

  return new Promise<Buffer>((resolve, reject) => {
    runGet(fileLink, (response) => {
      const wavBuffer: Buffer[] = [];
      const wavStream = response.pipe(getMpegDecoder());

      wavStream.on("data", (bufferPart) => wavBuffer.push(bufferPart));
      wavStream.on("error", (err) => reject(err));
      wavStream.on("end", () => resolve(Buffer.concat(wavBuffer)));
    }).on("error", (err) => reject(err));
  });
};
@mtripg6666tdr
Copy link

conversion maybe goes well by specifying '-f' and '-acodec'

@mtripg6666tdr
Copy link

exclude 'loglevel' from your args, write as following then you can see ffmpeg logs

const ffmpeg = new FFmpeg({/* options */});
ffmpeg.process.stderr.on("data", chunk => console.debug(chunk.toString()));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants