我想使用具有特定比特率的ffmpeg生成静音音频文件,并且持续时间少于一秒。我发现生成的音频文件没有所需的比特率。但是,如果我将持续时间延长到2秒,则比特率似乎是正确的。
例如:
ffmpeg -f lavfi -i anullsrc=r=22050:cl=mono -t 0.3 -acodec mp3 -ab 48k -y silence.mp3
生成的silence.mp3的比特率似乎不是48kb / s:
$ ffprobe silence.mp3
ffprobe version 3.4.2 Copyright (c) 2007-2018 the FFmpeg developers
built with Apple LLVM version 9.1.0 (clang-902.0.39.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mp3, from 'silence.mp3':
Metadata:
encoder : Lavf57.83.100
Duration: 00:00:00.37, start: 0.050113, bitrate: 52 kb/s
Stream #0:0: Audio: mp3, 22050 Hz, mono, s16p, 48 kb/s
如果持续时间为2秒,则比特率似乎还可以:
$ ffmpeg -f lavfi -i anullsrc=r=22050:cl=mono -t 2 -acodec mp3 -ab 48k -y silence.mp3
$ ffprobe silence.mp3
ffprobe version 3.4.2 Copyright (c) 2007-2018 the FFmpeg developers
built with Apple LLVM version 9.1.0 (clang-902.0.39.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mp3, from 'silence.mp3':
Metadata:
encoder : Lavf57.83.100
Duration: 00:00:02.06, start: 0.050113, bitrate: 48 kb/s
Stream #0:0: Audio: mp3, 22050 Hz, mono, s16p, 48 kb/s
有什么方法可以保持所需的比特率?