I have two videos.
i want to put second video on top of the first one, ideally in the corner.
To overlay a video on top of another video using fluent-ffmpeg, you need to use ffmpeg's overlay filter.
fluent-ffmpeg
ffmpeg
overlay
First, install fluent-ffmpeg:
npm install fluent-ffmpeg
If you don't have ffmpeg and ffprobe installed on your machine, make sure you do, or you can set their paths using fluent-ffmpeg.
ffprobe
Use the following code to overlay the second video (person_in_circle.mp4) on top of the first video (tutorial.mp4):
const ffmpeg = require('fluent-ffmpeg'); const inputMainVideo = 'tutorial.mp4'; const inputOverlayVideo = 'person_in_circle.mp4'; const outputVideo = 'output.mp4'; const overlayXPosition = "main_w-overlay_w"; const overlayYPosition = "0"; ffmpeg() .input(inputMainVideo) .input(inputOverlayVideo) .complexFilter([ { filter: 'overlay', options: { x: overlayXPosition, y: overlayYPosition }, inputs: ['0:v', '1:v'], outputs: 'result' } ], 'result') .on('end', function() { console.log('Finished processing'); }) .on('error', function(err) { console.error('Error:', err); }) .save(outputVideo);
Ensure the overlay video is smaller in dimension than the main video if you want it to be fully visible. If it's larger, you might need to resize it first using ffmpeg.
To overlay a video on top of another video using
fluent-ffmpeg
, you need to useffmpeg
'soverlay
filter.First, install
fluent-ffmpeg
:If you don't have
ffmpeg
andffprobe
installed on your machine, make sure you do, or you can set their paths usingfluent-ffmpeg
.Use the following code to overlay the second video (person_in_circle.mp4) on top of the first video (tutorial.mp4):
Ensure the overlay video is smaller in dimension than the main video if you want it to be fully visible. If it's larger, you might need to resize it first using
ffmpeg
.