J
J
Jourloy2021-12-15 17:07:38
fmpeg
Jourloy, 2021-12-15 17:07:38

Why is fluent-ffmpeg picking up wrong length videos?

I have a video, I split it into photos, process the photos and want to reassemble exactly the same video.
Until the last point, everything is going fine, but my video assembly is not going correctly

Let's say I have a video for 10 seconds. After building this video is already 14 seconds and when you turn it on, it feels like fluent-ffmpeg slows it down.

I tried to do the same, but not through NodeJS, but just from the console and everything went fine. The video was assembled in length the same as the original

Terminal command

ffmpeg -r 30/1 -I path_to_folder/frame-%d.jpeg -c:v libx264 -r 30 out.mp4

How am I trying to put together a video in NodeJS

I tried without FPS, and with one, and with two, and without a codec. I tried all the options, but the video is still some kind of slow

FFmpeg does not display any errors
const buildVideo: Promise<void> = new Promise((resolve, reject) => {
    const command = ffmpeg()
        .output(`${videoTmp.path}.mp4`)
        .input(`${tmpDir.path}/frame-%d.jpeg`)
        .input(`${audioTmp.path}.mp3`)
        .videoCodec('libx264')
        .inputFPS(30)
        .outputFPS(30)
        .on('error', (error) => {
            this.logger.error(`FFMPEG ERROR: ${error}`);
            reject(error);
        })
        .on('end', function () {
            resolve();
        })
        .run();
});

await buildVideo;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2021-12-15
@Jourloy

it's in the order of options:
in the NodeJS variant it -r 30comes after -i имяфайла and therefore does not apply to it. The default frequency of 25 is applied to the input as a result.
From the Fluent documentation :

The following methods enable passing input-related options to ffmpeg. Each of these methods apply on the last input added (including the one passed to the constructor, if any). You must add an input before calling those, or an error will be thrown.

Try specifying the option .inputFPS(30)immediately after.input(`${tmpDir.path}/frame-%d.jpeg`)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question