I'm getting a "No such file or directory" error even though the files exists and the path is correct Image for reference
Here is the code I have
// initialize imports
const ffmpeg = require('fluent-ffmpeg')
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path
const ffprobePath = require('@ffprobe-installer/ffprobe').path
// initialize paths for ffmpeg
ffmpeg.setFfmpegPath(ffmpegPath)
ffmpeg.setFfprobePath(ffprobePath)
// export merge function
module.exports.merge = async () => {
await ffmpeg('./viral.mp4')
.input('./rand_gta.mp4')
.complexFilter([
`[0:v]scale=576:1024[0scaled]`,
`[1:v]scale=576:512[1scaled]`,
`[0scaled]pad=576:1024[0padded]`,
`[0padded][1scaled]overlay=0:550[output]`,
])
.outputOptions(['-map 0:a', '-map [output]'])
.output('./out.mp4')
.on('error', function (er) {
console.log('error occured: ' er.message)
})
.on('progress', ({ percent }) => {
const value = percent.toFixed(2)
console.log(`Processing video: ${value}%`)
})
.run()
}
Any feedback, help. is very much appreciated
CodePudding user response:
Change the path from relative to absolute and check if the code works correctly. If it works, then your relative path is incorrect.
CodePudding user response:
I fixed the error by moving the video files in the root directory. the code now looks like this:
await ffmpeg('./content/viral.mp4')
.input('./content/rand_gta.mp4')
and the file structure is now:
root
|__content
|__viral.mp4
|__rand_gta.mp4