我正在开发一个电子应用程序,该应用程序运行ffmpeg命令以将音频文件+图像文件组合为视频文件。我使用的是我写的fluent-ffmpeg命令,该命令有效,但是即使我在命令中指定了320kbps,输出的视频文件也始终具有较低的音频比特率。
我已经使用下面记录的mp3 / flac / wav文件运行了多个测试;使用我的fluent-ffmpeg命令,如下所示:
ffmpeg()
.input(imgPath)
.loop()
.addInputOption('-framerate 2')
.input(audioPath)
.videoCodec('libx264')
.audioCodec('aac')
//.audioCodec('copy')
.audioBitrate('320k')
.videoBitrate('8000k', true)
.size('1920x1080')
.outputOptions([
'-preset medium',
'-tune stillimage',
'-crf 18',
'-b:a 320k',
'-pix_fmt yuv420p',
'-shortest'
])
.on('progress', function (progress) {
document.getElementById(updateInfoLocation).innerText = `Generating Video: ${Math.round(progress.percent)}%`
console.info(`vid() Processing : ${progress.percent} % done`);
})
.on('codecData', function (data) {
console.log('vid() codecData=', data);
})
.on('end', function () {
document.getElementById(updateInfoLocation).innerText = `Video generated.`
console.log('vid() file has been converted succesfully; resolve() promise');
resolve();
})
.on('error', function (err) {
document.getElementById(updateInfoLocation).innerText = `Error generating video.`
console.log('vid() an error happened: ' + err.message, ', reject()');
reject(err);
})
.output(vidOutput).run()
1)320bkps mp3文件
如果我将上述ffmpeg函数与.audioCodec('aac')
一起使用,则输出视频文件的音频比特率为 300kbps 。如果我改用.audioCodec('copy')
,则我的输出视频文件的音频比特率为 317kbps 。
2)1411kbps wav文件
我的wav文件的音频比特率为1411kbps;
当我使用.audioCodec('aac')
运行ffmpeg命令时,我的输出视频文件再次仅为 303kbps
3)937kbps flac文件
当我使用.audioCodec('aac')
运行ffmpeg命令时,输出的视频文件仅为 304kbps
是否需要添加任何命令或其他标志以确保输出的视频文件具有高质量的音频比特率?