2016-03-07 102 views
2

我試圖將字幕刻錄成視頻。此命令在命令行完美的作品: ffmpeg -i in.mp4 -vf subtitles=sub.srt:force_style='Fontsize=20' out.mp4使用流利-ffmpeg添加字幕

我在服務器端的代碼似乎並沒有做太多(它創建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!

回答

3

好吧,我發現我們的問題。這是.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