1

I'd like to generate a silence audio file using ffmpeg with specific bitrate and the duration is less than one second. I found that the generated audio file does not have the desired bitrate. But if I expand the duration to 2 seconds, the bitrate seems to be correct.

For example:

ffmpeg -f lavfi -i anullsrc=r=22050:cl=mono -t 0.3 -acodec mp3 -ab 48k -y silence.mp3

The generated silence.mp3's bitrate seems not 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

If the duration is 2 seconds, bitrate seems OK:

$ 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

Is there any way to keep the bitrate as desired?

bambooom
  • 664
  • 6
  • 15

0 Answers0