簡體   English   中英

使用 fluent-ffmpeg 添加字幕

[英]Adding subtitles with fluent-ffmpeg

我正在嘗試將字幕刻錄到視頻中。 此命令從命令行完美運行: ffmpeg -i in.mp4 -vf subtitles=sub.srt:force_style='Fontsize=20' out.mp4

我在服務器端的代碼似乎沒有做太多(雖然它創建了 test.mp4)

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');

我收到以下錯誤: Error: ffmpeg exited with code 1: Error opening filters!

好的,我找到了我們的問題。 .srt文件格式不正確。 為了比較,這是我們不正確的文件(=時間很重要):

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

這是正確的:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM