}
export namespace bitrate {
- export const baseKbitrate = 384
+ const baseKbitrate = 384
const toBits = (kbits: number): number => { return kbits * 8000 }
* See https://trac.ffmpeg.org/wiki/Encode/AAC#fdk_vbr
*/
async function standard (_ffmpeg) {
- let _bitrate = audio.bitrate.baseKbitrate
let localFfmpeg = _ffmpeg
.format('mp4')
.videoCodec('libx264')
return localFfmpeg.noAudio()
}
- // we try to reduce the ceiling bitrate by making rough correspondances of bitrates
- // of course this is far from perfect, but it might save some space in the end
- if (audio.bitrate[_audio.audioStream['codec_name']]) {
- _bitrate = audio.bitrate[_audio.audioStream['codec_name']](_audio.audioStream['bit_rate'])
- if (_bitrate === -1) {
- return localFfmpeg.audioCodec('copy')
- }
- }
-
// we favor VBR, if a good AAC encoder is available
if ((await checkFFmpegEncoders()).get('libfdk_aac')) {
return localFfmpeg
.audioQuality(5)
}
- return localFfmpeg.audioBitrate(_bitrate)
+ // we try to reduce the ceiling bitrate by making rough correspondances of bitrates
+ // of course this is far from perfect, but it might save some space in the end
+ const audioCodecName = _audio.audioStream['codec_name']
+ let bitrate: number
+ if (audio.bitrate[audioCodecName]) {
+ bitrate = audio.bitrate[audioCodecName](_audio.audioStream['bit_rate'])
+
+ if (bitrate === -1) return localFfmpeg.audioCodec('copy')
+ }
+
+ if (bitrate !== undefined) return localFfmpeg.audioBitrate(bitrate)
+
+ return localFfmpeg
}