how to embed seekbar inside a video using node-fluent-ffmpeg
.
Ex:-
Script:
Here's a working script that draws a 20px dark-red progress bar on the bottom of the video using only node's fluent-ffmpeg
. It requires a recent version of ffmpeg
installed to work (I used 4.0.2). You can change the bar color from DarkRed
to any valid ffmpeg
color, and change the height by setting bar_height
to the desire value in pixels.
#!/usr/bin/env node
var ffmpeg = require('fluent-ffmpeg');
let bar_height = 20;
let input_file = 'input_file.mp4';
let output_file = 'output_file.mp4';
ffmpeg.ffprobe(input_file, (err, data) => {
let input_duration = data.format.duration;
let progressBarGraph = [
{
inputs: '0',
filter: 'drawbox',
options: {
h: 'iw',
c: 'DarkRed',
width: 'iw',
thickness: 'fill'
},
outputs: 'rectangle'
},
{
inputs: ['0', 'rectangle'],
filter: 'overlay',
options: {
x: `-W+W*(t/${input_duration})`,
y: `H-${bar_height}`
},
outputs: "output"
}
];
ffmpeg(input_file).complexFilter(progressBarGraph, "output").output(output_file).run();
});
Sample Output:
Here's a screenshot of the output on a video file:
You can use a library like flowplayer as suggested in the documentation.
Also, after looking at the options provided by the plugin, you can write your own seekbar, you will need to follow these steps when the video is loaded to calculate it:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With