2

I want to use fluent-ffmpeg module to call ffmpeg with complex filter from Electron but have no success. The error '[AVFilterGraph @ 0xb8.......] No such filter " Error initalizing complex filters . Invalid argument' is the same as in this question Error : Running FFmpeg command in Android ,splitting command in array not working but the context is different.

What is needed? Run this ffmpeg command using fluent-ffmpeg:

ffmpeg -i safework-background-0.mp4 -i image1.png -i image2.png -i image3.png -filter_complex "[0:v][1:v] overlay=1:1:enable='between(t,5,8.5)' [tmp]; [tmp][2:v] overlay=1:1:enable='between(t,8.5,12)' [tmp]; [tmp][3:v] overlay=1:1:enable='between(t,12,15)'" test-video-safework3.mp4

It uses a complex filter to overlay three images on a video in sequence and exports a new video.

What doesn't work? Obviously fluent-ffmpeg chokes with required quotes for complex filter, that is my conclusion (and is the same as for the Android variant question above).

What works without fluent-ffmpeg in Electron? As you can guess I have to resort to calling ffmpeg directly. To help others, the following command, with input and output video filenames parametrized, translates to Electron as:

  var spawn = require('child_process').spawn
  var fargs = ['-y', '-i', sourceDir.path() + '/' + inVideoName, '-i', tempDir.path() + '/' + 'image1.png',
  '-i', tempDir.path() + '/' + 'image2.png', '-i', tempDir.path() + '/' + 'image3.png',
  '-filter_complex', '[0:v][1:v]overlay=1:1:enable=\'between(t,5,8.5)\'[tmp];' +
  '[tmp][2:v]overlay=1:1:enable=\'between(t,8.5,12)\'[tmp];[tmp][3:v]' +
  'overlay=1:1:enable=\'between(t,12,15)\'', targetDir.path() + '/' + outVideoName]
  var ffmpeg = spawn(ffmpegc, fargs, { cwd:jetpack.cwd(app.getPath('home')).path() })
// some code ommitted
  ffmpeg.on('close', (code) => {
    console.log(`child process exited with code ${code}`)
    webContents.send('notify-user-reply', 'Video processing done.')
  })

The above command already has removed spaces between various filters (in complex filter) for each image or it would also choke.

I would really love to use fluent-ffmpeg in Electron, not just for the convenience of calling ffmpeg more elegantly but also for some additional features like easy progress reporting.

Community
  • 1
  • 1
Matt Sergej Rinc
  • 565
  • 3
  • 11

0 Answers0