2

Im a beginner to ffmpeg. I want to set a gif animation as an overlay of input video from a x seconds to y second . I tried the following codes

var wmimage= 'public/source/watermark_file.gif';

ffmpeg('public/source/small.mp4')
.addOption(['-ignore_loop 0', '-i '+wmimage+ '','-filter_complex [0:v][1:v]overlay=10:10:shortest=1:'])
.save('public/video/output-video2.mp4');

This gives me gif animation overlay from start to end of the input video length. but i need to show the gif for a duration (eg: from :2second to: 5second). So i tried to adding

enable="between(t,2,5)" at

.addOption(['-ignore_loop 0', '-i '+wmimage+ '','-filter_complex [0:v][1:v]overlay=10:10:shortest=1:enable="between(t,2,5)"'])

But it throws

Error: ffmpeg exited with code 1: Error initializing complex filters.
Invalid argument

I tried the enable option before overlay and shortest. but gives the same error.

Any help will appreciated.

Akhil P M
  • 174
  • 1
  • 2
  • 13

2 Answers2

0

Finally I got the solution. it was simple. my previous code was

.addOption(['-ignore_loop 0', '-i '+wmimage+ '','-filter_complex [0:v][1:v]overlay=10:10:shortest=1:enable="between(t,2,5)"'])

and replaces single quote with double and vice versa.

.addOption(["-ignore_loop 0", "-i "+wmimage+ "","-filter_complex [0:v][1:v]overlay=10:10:shortest=1:enable='between(t,2,5)'"])

So each quotes have importance in ffmpeg.

Akhil P M
  • 174
  • 1
  • 2
  • 13
0
 ffmpeg().input(`uploads/4444.mp4`).input('music/Bekind.mp3').input(`https://media.giphy.com/media/dS1rQkeAlZbmo/giphy.gif`).complexFilter('[2:v]scale=100:100[wat],[0:v][wat]overlay=10:10').addOption('-map 0:v').addOption('-map 1:a').videoCodec('libx264').output(`./downloads/444.mp4`).on('error', function(err, stdout, stderr) {
    console.log('Cannot process video: ' + err.message);
  }).on('end', function() {
    console.log('Finished processing');**my gif is not looping only please help**
  • 1
    Hi Suraj, can you please provide more explanation to your answer. Code only answers don't benefit anyone for understanding – Matt Moore Oct 02 '20 at 20:13