Ticket #431 (closed defect: fixed)
When converting audio to an MP3 using CBR, result is reported VBR
| Reported by: | schtorch | Owned by: | michael |
|---|---|---|---|
| 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%)
Change History
comment:1 in reply to: ↑ description Changed 21 months ago by cehoyos
- Status changed from new to open
- Component changed from FFmpeg to undetermined
comment:2 Changed 21 months ago by schtorch
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 Changed 21 months ago by cehoyos
Does the problem disappear if you disable the call to mp3_write_xing() in mp3_write_header() in libavformat/mp3enc.c?
comment:5 Changed 21 months ago by schtorch
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 Changed 21 months ago by cehoyos
Sorry, I meant
ffmpeg -i test_orig.mp3 -ab 128k -f mp3 - >test_ffmpeg_cbr.mp3
comment:7 Changed 21 months ago by schtorch
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 Changed 21 months ago by schtorch
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 Changed 21 months ago by cehoyos
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.)
comment:10 follow-up: ↓ 11 Changed 21 months ago by 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). 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 in reply to: ↑ 10 Changed 21 months ago by cehoyos
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 Changed 21 months ago by schtorch
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 Changed 20 months ago by schtorch
Please let me know if I should clarify anything or if I can help you in any way to fix that.
comment:15 Changed 19 months ago by michael
Maybe fixed, please test with latest git master
comment:16 Changed 18 months ago by schtorch
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
comment:17 Changed 18 months ago by cehoyos
- Status changed from open to closed
- Resolution set to fixed
Thank you for testing!



Replying to schtorch:
Do you think this is a regression?