Opened 6 years ago
Last modified 6 years ago
#8763 new defect
ffmpeg doesn't output lame vbr header correctly
| Reported by: | spotter | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | undetermined |
| Version: | unspecified | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
Summary of the bug: lame includes the xing header that defines the VBR quality level that was used. ffmpeg inserts the header, but seems to include incorrect values.
one can see this by inspecting the file with mediainfo a file encoded with lame -V0 shows
Audio
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Format settings : Joint stereo
Duration : 3 min 56 s
Bit rate mode : Variable
Bit rate : 280 kb/s
Minimum bit rate : 32.0 kb/s
Channel(s) : 2 channels
Sampling rate : 44.1 kHz
Frame rate : 38.281 FPS (1152 SPF)
Compression mode : Lossy
Stream size : 7.89 MiB (100%)
Writing library : LAME3.100
Encoding settings : -m j -V 0 -q 0 -lowpass 22.1 --vbr-new -b 32
while a file encoded with ffmpeg -q:a 0 (per https://trac.ffmpeg.org/wiki/Encode/MP3)
shows
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Format settings : Joint stereo
Duration : 3 min 56 s
Bit rate mode : Variable
Bit rate : 280 kb/s
Channel(s) : 2 channels
Sampling rate : 44.1 kHz
Frame rate : 38.281 FPS (1152 SPF)
Compression mode : Lossy
Stream size : 7.89 MiB (100%)
Writing library : LAME3.100
so first thing we note is data seems to be the same, but ffmpeg doesn't include the Encoder settings. so what happens if we use ffmpeg to copy the lame encoded file (above) into an mp3 (in this case, getting the id3 tags from another file)
then we see
Audio
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Format settings : Joint stereo
Duration : 3 min 56 s
Bit rate mode : Variable
Bit rate : 280 kb/s
Channel(s) : 2 channels
Sampling rate : 44.1 kHz
Frame rate : 38.281 FPS (1152 SPF)
Compression mode : Lossy
Stream size : 7.89 MiB (100%)
Writing library : LAME3.100
Encoding settings : -m m -V 10 -q 0
that's weird. it now output the encoding settings, but messed with them.
inspecting the all 3 files with Mpeg Audio Info (which can decode the xing header, haven't found a linux utility that can do it, but it runs in wine without a problem, https://www.codeproject.com/Articles/8295/MPEG-Audio-Frame-Header ). It shows the lame encoded file as having quality 100, but the ffmpeg copied and ffmpeg encoded files as having Quality 0.
version of ffmpeg: ffmpeg version 4.2.2-1ubuntu1
Change History (3)
comment:1 by , 6 years ago
| Version: | 4.2 → unspecified |
|---|
comment:2 by , 6 years ago
built with ./configure --enable-libmp3lame && make (configure lists mp3 as a decoder, but not as encoder)
ffmpeg version N-98341-gcca982ee01
./ffmpeg -i input.flac -codec:a libmp3lame -q:a 0 /tmp/test2.mp3
while they don't return the same exact bits (md5sums differ), the ffmpeg files are the same exact sizes and it has the same xing header issue.
comment:3 by , 6 years ago
./ffmpeg -i input.flac -codec:a libmp3lame -q:a 0 /tmp/test2.mp3
ffmpeg version N-98341-gcca982ee01 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
configuration: --enable-libmp3lame --enable-encoder=mp3
libavutil 56. 55.100 / 56. 55.100
libavcodec 58. 93.100 / 58. 93.100
libavformat 58. 47.100 / 58. 47.100
libavdevice 58. 11.100 / 58. 11.100
libavfilter 7. 86.100 / 7. 86.100
libswscale 5. 8.100 / 5. 8.100
libswresample 3. 8.100 / 3. 8.100
Input #0, flac, from 'input.flac':
Metadata:
disc : 1
TOTALDISCS : 2
TOTALTRACKS : 18
Duration: 00:03:56.29, start: 0.000000, bitrate: 977 kb/s
Stream #0:0: Audio: flac, 44100 Hz, stereo, s16
File '/tmp/test2.mp3' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:0 -> #0:0 (flac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
Output #0, mp3, to '/tmp/test2.mp3':
Metadata:
TPOS : 1
TOTALDISCS : 2
TOTALTRACKS : 18
TSSE : Lavf58.47.100
Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p
Metadata:
encoder : Lavc58.93.100 libmp3lame
size= 8084kB time=00:03:56.30 bitrate= 280.3kbits/s speed=41.6x
video:0kB audio:8084kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.005883%



Please test current FFmpeg git head and provide the command line you tested together with the complete, uncut console output to make this a valid ticket.