我正在尝试使用 在视频上刻录字幕,fluent-ffmpeg
但是刻录后字幕变得模糊。
我尝试过多种设置组合,但都无法产生像 VLC 那样好的质量。
这些是我使用的设置:
function processVideo(localTempPath) {
return new Promise((resolve, reject) => {
ffmpeg()
.input("xx.mp4")
.videoFilter([
{
filter: 'subtitles',
options: "gaza_edit.ass",
expression: 'subtitles'
},
'scale=-1:360'
])
// .inputOptions('-scodec mov_text')
.withVideoCodec("libx264")
.withAudioCodec("copy")
.withOutputFormat("mp4")
/**
* ou control the tradeoff between video encoding speed and compression efficiency with the -preset options.
* Those are ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow. Default is medium.
* The veryslow option offers the best compression efficiency (resulting in a smaller file size for the same quality) but it is very slow – as the name says.
*/
.outputOptions("-preset veryfast")
.outputOptions('-max_muxing_queue_size 1024') // Add max_muxing_queue_size option for output
// .outputOptions("-s 1280x720")
// .outputOptions("-sws_flags lanczos")
// .outputOptions(['-x264-params crf=18'])
.output("output.mp4")
.on("error", (error) => reject("Failed to process video: " + error))
.on("progress", (progress) => console.log(progress))
.on('end', function () {
console.log('Finished processing');
})
.run();
});;
}
1 很模糊
2 更加清晰