Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding subtitles with fluent-ffmpeg

I'm trying to burn in subtitles into a video. This command works perfectly from command line: ffmpeg -i in.mp4 -vf subtitles=sub.srt:force_style='Fontsize=20' out.mp4

My code on server side doesn't seem to do much (it creates test.mp4 though)

ffmpeg('temp/subtitleVideos/qTWVbM5pkKms_pJbE8OAvH3N.mp4')
            .outputOptions(
                '-vf subtitles=temp/subtitleVideos/qTWVbM5pkKms_pJbE8OAvH3N.srt'
            )
            .on('error', function(err) {
                console.log('Error: ' + err.message);
            })
            .save(path + 'test.mp4');

and I get the following error: Error: ffmpeg exited with code 1: Error opening filters!

like image 897
eZo Avatar asked Oct 19 '22 14:10

eZo


1 Answers

Ok, I've found our problem. It was incorrect format of .srt file. To compare, this is our incorrect file (=timing is important):

1
00:00:00 --> 00:00:03
kitty cat

2
00:00:03,372 --> 00:00:05,674
is sitting

3
00:00:05,795 --> 00:00:08,905
on a pad

and this one is correct:

1
00:00:00,828 --> 00:00:03,130
kitty cat

2
00:00:03,372 --> 00:00:05,674
is sitting

3
00:00:05,795 --> 00:00:08,905
on a pad
like image 193
eZo Avatar answered Oct 29 '22 17:10

eZo