#431 closed defect (fixed)
When converting audio to an MP3 using CBR, result is reported VBR
Reported by: | schtorch | Owned by: | Michael Niedermayer |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | git-master | Keywords: | CBR mp3 |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
When I try to convert a file to MP3 with CBR using the latest GIT, I get a file which is reported by various players (mediainfo, VLC) to be a variable bitrate (VBR) file.
ffmpeg -i test_orig.mp3 -ab 128k test_ffmpeg_cbr.mp3 ffmpeg version N-32327-g27bf599, Copyright (c) 2000-2011 the FFmpeg developers built on Sep 5 2011 21:57:49 with gcc 4.5.1 20101208 [gcc-4_5-branch revision 167585] configuration: --shlibdir=/usr/lib64 --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib64 --enable-shared --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libxvid --enable-postproc --enable-gpl --disable-network --extra-cflags='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -fPIC -I/usr/include/gsm' --disable-stripping --enable-libschroedinger --enable-libdirac --enable-libgsm --enable-avfilter --enable-libvpx --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-pthreads --enable-libfaac --enable-nonfree --disable-doc --disable-ffplay --disable-ffserver libavutil 51. 16. 0 / 51. 16. 0 libavcodec 53. 13. 0 / 53. 13. 0 libavformat 53. 11. 0 / 53. 11. 0 libavdevice 53. 3. 0 / 53. 3. 0 libavfilter 2. 37. 0 / 2. 37. 0 libswscale 2. 1. 0 / 2. 1. 0 libpostproc 51. 2. 0 / 51. 2. 0 [mp3 @ 0x6319e0] max_analyze_duration 5000000 reached at 5015510 Input #0, mp3, from 'test_orig.mp3': Duration: 00:03:31.61, start: 0.000000, bitrate: 128 kb/s Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s File 'test_ffmpeg_cbr.mp3' already exists. Overwrite ? [y/N] y Output #0, mp3, to 'test_ffmpeg_cbr.mp3': Metadata: TSSE : Lavf53.11.0 Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s Stream mapping: Stream #0.0 -> #0.0 (mp3 -> libmp3lame) Press [q] to stop, [?] for help size= 3307kB time=00:03:31.64 bitrate= 128.0kbits/s video:0kB audio:3307kB global headers:0kB muxing overhead 0.005581%
mediainfo test_ffmpeg_cbr.mp3 General Complete name : test_ffmpeg_cbr.mp3 Format : MPEG Audio File size : 3.23 MiB Duration : 3mn 31s Overall bit rate : 128 Kbps Encoding settings : Lavf53.11.0 Audio Format : MPEG Audio Format version : Version 1 Format profile : Layer 3 Mode : Joint stereo Mode extension : MS Stereo Duration : 3mn 31s Bit rate mode : Variable Bit rate : 128 Kbps Channel(s) : 2 channels Sampling rate : 44.1 KHz Stream size : 3.23 MiB (100%)
Attachments (1)
Change History (23)
comment:1 by , 13 years ago
Component: | FFmpeg → undetermined |
---|---|
Status: | new → open |
comment:2 by , 13 years ago
It seems it has worked before. Here is a comment I found on the ffmpeg user mailinglist:
http://ffmpeg-users.933282.n4.nabble.com/mp3-bitrate-vlc-td3548853.html
Another info, I tried to use lame directly and mediainfo reports a correct bit rate mode.
# lame --preset cbr 128k test_orig.mp3 test_lame_cbr.mp3 ID3v2 found. Be aware that the ID3 tag is currently lost when transcoding. LAME 3.98.4 64bits (http://www.mp3dev.org/) Using polyphase lowpass filter, transition band: 16538 Hz - 17071 Hz Encoding test_orig.mp3 to test_lame_cbr.mp3 Encoding as 44.1 kHz j-stereo MPEG-1 Layer III (11x) 128 kbps qval=3 Frame | CPU time/estim | REAL time/estim | play/CPU | ETA 8102/8103 (100%)| 0:05/ 0:05| 0:05/ 0:05| 37.393x| 0:00 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- kbps LR MS % long switch short % 128.0 3.3 96.7 84.8 8.9 6.3 Writing LAME Tag...done ReplayGain: -8.6dB
# mediainfo test_lame_cbr.mp3 General Complete name : test_lame_cbr.mp3 Format : MPEG Audio File size : 3.23 MiB Duration : 3mn 31s Overall bit rate : 128 Kbps Writing library : LAME3.98r Audio Format : MPEG Audio Format version : Version 1 Format profile : Layer 3 Mode : Joint stereo Mode extension : MS Stereo Duration : 3mn 31s Bit rate mode : Constant Bit rate : 128 Kbps Channel(s) : 2 channels Sampling rate : 44.1 KHz Stream size : 3.23 MiB (100%) Writing library : LAME3.98r Encoding settings : -m j -V 4 -q 3 -lowpass 17 -b 128
comment:3 by , 13 years ago
Does the problem disappear if you disable the call to mp3_write_xing() in mp3_write_header() in libavformat/mp3enc.c?
comment:5 by , 13 years ago
Uncommenting mp3_write_xing() seems to work, bit rate mode changes to constant.
mediainfo test_ffmpeg_cbr.mp3 General Complete name : test_ffmpeg_cbr.mp3 Format : MPEG Audio File size : 3.23 MiB Duration : 3mn 31s Overall bit rate : 128 Kbps Encoding settings : Lavf53.11.0 Audio Format : MPEG Audio Format version : Version 1 Format profile : Layer 3 Mode : Joint stereo Mode extension : MS Stereo Duration : 3mn 31s Bit rate mode : Constant Bit rate : 128 Kbps Channel(s) : 2 channels Sampling rate : 44.1 KHz Stream size : 3.23 MiB (100%)
# ffmpeg -i test_orig.mp3 -ab 128k - >test_ffmpeg_cbr.mp3 ... [NULL @ 0x632280] Unable to find a suitable output format for 'pipe:' pipe:: Invalid argument
comment:6 by , 13 years ago
Sorry, I meant
ffmpeg -i test_orig.mp3 -ab 128k -f mp3 - >test_ffmpeg_cbr.mp3
comment:7 by , 13 years ago
This also works like a charm and results in a correct bit rate mode:
# ffmpeg -i test_orig.mp3 -ab 128k -f mp3 - >test_ffmpeg_cbr.mp3
# mediainfo test_ffmpeg_cbr.mp3 General Complete name : test_ffmpeg_cbr.mp3 Format : MPEG Audio File size : 3.23 MiB Duration : 3mn 31s Overall bit rate : 128 Kbps Encoding settings : Lavf53.11.0 Audio Format : MPEG Audio Format version : Version 1 Format profile : Layer 3 Mode : Joint stereo Mode extension : MS Stereo Duration : 3mn 31s Bit rate mode : Constant Bit rate : 128 Kbps Channel(s) : 2 channels Sampling rate : 44.1 KHz Stream size : 3.23 MiB (100%)
comment:8 by , 13 years ago
Please let me know, if I can help further...
Using the piping mechanism might be a workaround, but the resulting files include sometimes some "digital burbs"...
comment:9 by , 13 years ago
Could you explain what the problem with the resulting file is if you do not use the pipe?
(The files are CBR except for the initial Xing header.)
follow-up: 11 comment:10 by , 13 years ago
I see the problem that the bitrate and bit rate mode is reported wrong in a lot of players (e.g. VLC states 56k for a 128k CBR without initial Xing header). This might be at first sight a more cosmetic issue but confuses people when they want to verify if it's a CBR or what bitrate the file exactly has without using a calculator and the file size.
The reason to verify if it's a CBR are compatibility problems with players that do not support MP3 VBR, eg. some mobiles or software in older hardware. Maybe (just guessing) there is also a problem that players that only support CBR do not play files "marked as VBR" that are in reality CBR files.
I would really appreciate a fix.
comment:11 by , 13 years ago
Replying to schtorch:
I see the problem that the bitrate and bit rate mode is reported wrong in a lot of players (e.g. VLC states 56k for a 128k CBR without initial Xing header).
Do I understand correctly that the bitrate is shown incorrectly if there is no Xing Header (=if you use the pipe)?
comment:12 by , 13 years ago
Ok, I have misunderstood you. The pipe is working correctly as stated in comment 7. Changing source code also worked correctly in comment 5. So the problem stated in comment 11 is when I use ffmpeg from GIT without piping. And that implies using the Xing Header if I understand you correctly.
comment:13 by , 13 years ago
Please let me know if I should clarify anything or if I can help you in any way to fix that.
comment:14 by , 13 years ago
Keywords: | mp3 added |
---|
comment:16 by , 13 years ago
This is fixed indeed!
Test CBR:
$ ffmpeg -i test.mp4 -ab 128k test.mp3 ffmpeg version N-34877-g53cb0de, Copyright (c) 2000-2011 the FFmpeg developers built on Nov 15 2011 16:26:55 with gcc 4.5.1 20101208 [gcc-4_5-branch revision 167585] configuration: --enable-gpl --enable-version3 --enable-shared --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvorbis --enable-libtheora --enable-libvpx --enable-libspeex --enable-libxvid --enable-libx264 --disable-network --disable-stripping --enable-libschroedinger --enable-libdirac --enable-libgsm --enable-avfilter --enable-pthreads --disable-doc --disable-ffplay --disable-ffserver --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib libavutil 51. 25. 0 / 51. 25. 0 libavcodec 53. 34. 0 / 53. 34. 0 libavformat 53. 20. 0 / 53. 20. 0 libavdevice 53. 4. 0 / 53. 4. 0 libavfilter 2. 48. 1 / 2. 48. 1 libswscale 2. 1. 0 / 2. 1. 0 libpostproc 51. 2. 0 / 51. 2. 0 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.87.1 Duration: 00:00:55.28, start: 0.000000, bitrate: 618 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 400x222, 485 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc Metadata: creation_time : 1970-01-01 00:00:00 handler_name : VideoHandler Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 127 kb/s Metadata: creation_time : 1970-01-01 00:00:00 handler_name : File 'test.mp3' already exists. Overwrite ? [y/N] y Output #0, mp3, to 'test.mp3': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 TDEN : 1970-01-01 00:00:00 TSSE : Lavf53.20.0 Stream #0:0(und): Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s Metadata: creation_time : 1970-01-01 00:00:00 handler_name : Stream mapping: Stream #0:1 -> #0:0 (aac -> libmp3lame) Press [q] to stop, [?] for help size= 864kB time=00:00:55.24 bitrate= 128.1kbits/s video:0kB audio:863kB global headers:0kB muxing overhead 0.066065%
Result CBR:
mediainfo test.mp3 General Complete name : test.mp3 Format : MPEG Audio File size : 864 KiB Duration : 55s 275ms Overall bit rate : 128 Kbps Encoded date : UTC 1970-01- 1 00:00:00 Writing library : LAME3.99 Encoding settings : Lavf53.20.0 major_brand : isom minor_version : 512 compatible_brands : isomiso2avc1mp41 Audio Format : MPEG Audio Format version : Version 1 Format profile : Layer 3 Mode : Joint stereo Mode extension : MS Stereo Duration : 55s 275ms Bit rate mode : Constant Bit rate : 128 Kbps Channel(s) : 2 channels Sampling rate : 44.1 KHz Stream size : 864 KiB (100%) Writing library : LAME3.99
Test VBR:
$ ffmpeg -i test.mp4 -qscale 1 test.mp3 ffmpeg version N-34877-g53cb0de, Copyright (c) 2000-2011 the FFmpeg developers built on Nov 15 2011 16:26:55 with gcc 4.5.1 20101208 [gcc-4_5-branch revision 167585] configuration: --enable-gpl --enable-version3 --enable-shared --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvorbis --enable-libtheora --enable-libvpx --enable-libspeex --enable-libxvid --enable-libx264 --disable-network --disable-stripping --enable-libschroedinger --enable-libdirac --enable-libgsm --enable-avfilter --enable-pthreads --disable-doc --disable-ffplay --disable-ffserver --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib libavutil 51. 25. 0 / 51. 25. 0 libavcodec 53. 34. 0 / 53. 34. 0 libavformat 53. 20. 0 / 53. 20. 0 libavdevice 53. 4. 0 / 53. 4. 0 libavfilter 2. 48. 1 / 2. 48. 1 libswscale 2. 1. 0 / 2. 1. 0 libpostproc 51. 2. 0 / 51. 2. 0 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 creation_time : 1970-01-01 00:00:00 encoder : Lavf52.87.1 Duration: 00:00:55.28, start: 0.000000, bitrate: 618 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 400x222, 485 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc Metadata: creation_time : 1970-01-01 00:00:00 handler_name : VideoHandler Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 127 kb/s Metadata: creation_time : 1970-01-01 00:00:00 handler_name : File 'test.mp3' already exists. Overwrite ? [y/N] y Output #0, mp3, to 'test.mp3': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 TDEN : 1970-01-01 00:00:00 TSSE : Lavf53.20.0 Stream #0:0(und): Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s Metadata: creation_time : 1970-01-01 00:00:00 handler_name : Stream mapping: Stream #0:1 -> #0:0 (aac -> libmp3lame) Press [q] to stop, [?] for help size= 1849kB time=00:00:55.24 bitrate= 274.2kbits/s video:0kB audio:1849kB global headers:0kB muxing overhead 0.030847%
Result VBR:
mediainfo test.mp3 General Complete name : test.mp3 Format : MPEG Audio File size : 1.81 MiB Encoded date : UTC 1970-01- 1 00:00:00 Writing library : LAME3.99 Encoding settings : Lavf53.20.0 major_brand : isom minor_version : 512 compatible_brands : isomiso2avc1mp41 Audio Format : MPEG Audio Format version : Version 1 Format profile : Layer 3 Mode : Joint stereo Mode extension : MS Stereo Bit rate mode : Variable Channel(s) : 2 channels Sampling rate : 44.1 KHz Stream size : 1.81 MiB (100%) Writing library : LAME3.99
by , 8 years ago
Attachment: | 20160921_112559_capture.png added |
---|
comment:18 by , 8 years ago
Seems that the problem is back (or has not been fixed completely). This is the offending command line:
ffmpeg.exe -i infile.mp4 -loglevel error -stats -y -c:v libxvid -b:v 1750k -c:a libmp3lame -b:a 128k -async 1 outfile.avi
Here's what ffprobe has to say:
ffprobe -v error infile.mp4
ffprobe version N-78197-g5893e87 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --
enable-lzma --enable-decklink --enable-zlib
libavutil 55. 16.101 / 55. 16.101
libavcodec 57. 22.102 / 57. 22.102
libavformat 57. 23.101 / 57. 23.101
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 27.100 / 6. 27.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'infile.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-03-17 10:20:35
Duration: 00:03:48.74, start: 0.000000, bitrate: 3027 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720
[SAR 1:1 DAR 16:9], 2833 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, flt
p, 191 kb/s (default)
Metadata:
creation_time : 2016-03-17 10:20:37
handler_name : IsoMedia File Produced by Google, 5-11-2011
ffprobe outfile.avi
ffprobe version N-78197-g5893e87 Copyright (c) 2007-2016 the FFmpeg developers
built with gcc 5.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --
enable-lzma --enable-decklink --enable-zlib
libavutil 55. 16.101 / 55. 16.101
libavcodec 57. 22.102 / 57. 22.102
libavformat 57. 23.101 / 57. 23.101
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 27.100 / 6. 27.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, avi, from 'outfile.avi':
Metadata:
encoder : Lavf57.23.101
Duration: 00:02:35.09, start: 0.000000, bitrate: 1922 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (xvid / 0x64697678), yuv420p, 128
0x720 [SAR 1:1 DAR 16:9], 1788 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 k
b/s
ffmpeg.exe -version
ffmpeg version N-78197-g5893e87 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avis
ynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable
-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --en
able-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-lib
ilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable
-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enab
le-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enabl
e-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc -
-enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-
libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --en
able-lzma --enable-decklink --enable-zlib
libavutil 55. 16.101 / 55. 16.101
libavcodec 57. 22.102 / 57. 22.102
libavformat 57. 23.101 / 57. 23.101
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 27.100 / 6. 27.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Screenshot from VirtualDub attached, it seems that is sees the MP3 stream encoded as "VBR" with a bitrate of exactly 128k. Unfortunately, this breaks compatibility with some hardware players and contradicts what -c:a libmp3lame -b:a 128k is advertised to do.
Thanks for having a look.
comment:19 by , 8 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:20 by , 8 years ago
volker,
I just tested ffmpeg git master with encoding an aac to -c:a libmp3lame -b:a 128k in avi. mediainfo reports "Bit rate mode : Constant" for the audio. Can you check your file with mediainfo to see if it says the same?
Thanks
comment:21 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Please do not reopen ancient tickets using a new, different command line.
comment:22 by , 8 years ago
Sorry for reopening this ticket again, but it seems that this was never really fixed.
Every time a open with VirtualDub an AVI made with ffmpeg (no matter the version), it warns about "Variable Bitrate (VBR) audio detected". But it's ok with AVIs made with Mencoder!
Now I'm trying to analyze some AVIs to find differences with AVIs made with mpeg4 native encoder and libxvid (because mpeg4 doesn't make really compliant XviD files for some reason or default option...) and I just found a program called AVInaptic.
And with AVInaptic I found a big difference:
AVIs made with ffmpeg, appart from the field "Bitrate (bs)" which says "128 kbps CBR" (that should be the field also reads MediaInfo) have an extra field called just "Bitrate" which says "128 kbps VBR" and that should be what VirtualDub reads, and may be what causes problems in some DVD Players??
Replying to schtorch:
Do you think this is a regression?