如果我直接从mp3转换为mp4,一切都很完美。但是,如果我尝试从原始pcm转换,音频速度会变慢。
我尝试了以下(这项工作):
ffmpeg -i mp3/1.mp3 -strict -2 final.mp4
这并没有按预期工作:
ffmpeg -f s16le -i final.raw -strict -2 -r 26 final.mp4
使用以下输出:
Input #0, s16le, from 'final.raw':
Duration: 00:08:37.38, bitrate: 705 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, 1 channels, s16, 705 kb/s
File 'final.mp4' already exists. Overwrite ? [y/N] y
Output #0, mp4, to 'final.mp4':
Metadata:
encoder : Lavf56.40.101
Stream #0:0: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, mono, fltp, 128 kb/s
Metadata:
encoder : Lavc56.60.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
size= 8273kB time=00:08:37.38 bitrate= 131.0kbits/s
video:0kB audio:8185kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.073808%
我试图设置如下参数:
ffmpeg -ar 44100 -f s16le -i final.raw -strict -2 -r 26 final.mp4
没有运气。
为了从mp3获取PCM,我使用nodejs lame decoder:
var decoder = new lame.Decoder({
channels: 2,
bitDepth: 16,
sampleRate: 44100,
bitRate: 128,
outSampleRate: 44100, // 22050
mode: lame.STEREO
});