Yes, you can merge audio from an overlay video with the main video using the fluent-ffmpeg
library in NodeJS, a sequential process is followed. First, both the main video and the overlay video containing the desired audio are specified as inputs.
Then, the complexFilter
method is employed to apply the overlay filter, positioning the overlay video onto the main video. Within this filter, parameters such as overlay coordinates (x and y) and post-file end behavior (eof_action) are defined. The inputs and outputs for the complex filter are then specified, with references to the video streams of the main and overlay videos labeled as ‘0:v’ and ‘1:v’, respectively.
The ‘output’ label is the resulting stream post-overlay application. Following this, the output file path for the merged video is specified using the saveToFile
method. Optional event handling for ‘end’ and ‘error’ events is included to signal video generation completion and handle encountered errors. Through the execution of this code, fluent-ffmpeg effectively overlays the video from the overlay input onto the main input while retaining the audio from the overlay video. It is important to ensure accurate input video paths, adjust overlay positioning as necessary, and appropriately manage any potential processing errors.
You can refer to these threads for more understanding: