Merge Videos using fluent-ffmpeg

46 views Asked by At

I'm trying to merge two videos, the following code works perfectly on windows 10, but it gives me an error when trying to run it on linux/ubuntu, same on wsl

    async joinVideo(): Promise<boolean> {
        return new Promise((resolve, reject) => {
            signale.info('Joining video')
            const profile = path.join(__dirname, '../videos/input/profile.mp4')
            const sb = path.join(__dirname, '../videos/input/sb.mp4')

            const joined = path.join(__dirname, '../videos/profile-sb.mp4')
            const tempFolder = path.join(__dirname, '../videos/temp')

            ffmpeg({ source: profile })
                .input(sb)
                .on('end', () => {
                    signale.success('Video joined')
                    resolve(true)
                })
                .on('error', err => {
                    signale.error(err)
                    reject(false)
                })
                .mergeToFile(joined, tempFolder)
        })
    }

The error i get

Error: ffmpeg exited with code 1: Error reinitializing filters! 
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0
Conversion failed!

    at ChildProcess.<anonymous> (/mnt/c/Users/Anri/Desktop/lead-gif-generator/node_modules/.pnpm/[email protected]/node_modules/fluent-ffmpeg/lib/processor.js:182:22)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:489:12)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:292:12)

the installation of fluent-ffmpeg should be correct as other operations are working, only mergeToFile function is erroring out

also strange thing is that if i put same file in both inputs it works fine, my guess it happens because of differance between videos, but why it works on windows

0

There are 0 answers