#797965 ffmpeg destroys gapless playback on (at least) MP3s

Package:
libavformat-dev
Source:
ffmpeg
Description:
FFmpeg library with (de)muxers for multimedia containers - development files
Submitter:
Christoph Anton Mitterer
Date:
2022-04-29 04:00:02 UTC
Severity:
normal
Tags:
#797965#5
Date:
2015-09-04 00:31:26 UTC
From:
To:
Hi.

It seems that bs1770gain somehow "destroys" gapless playback
on (at least) lame encoded MP3s.

For example, when I encode gapless WAV files via e.g.:
lame --verbose -q 0 -v -V 3 --noreplaygain --id3v2-utf16 --add-id3v2 --id3v1-only 1.wav
lame --verbose -q 0 -v -V 3 --noreplaygain --id3v2-utf16 --add-id3v2 --id3v1-only 2.wav
than the resulting 1.mp3 and 2.mp3 play flawlessly gapless
with e.g. mpv or on the ipod (mplayer or totem don't seem to
support gapless playback at all).

But once after I did e.g.:
$ bs1770gain -ismrpt --replaygain -o r/ music/
or:
$ bs1770gain -ismrpt  -o e/ music/
(with music containing the two MP3s) then the resulting MP3s in
e/ rspectively r/ no longer play gaplessly, neither with mpv
nor on the ipod.

When I do however:
$ collectiongain --regain music/
using the ReplayGain implementation from the python-rgain
package,
then the resulting files still play perfectly gapless
in mpv/ipod.


Cheers,
Chris.


PS: I've already notified upstream about this in a private
mail.

#797965#10
Date:
2015-09-04 21:02:17 UTC
From:
To:
Peter (=upstream) has asked me off list to check whether:
$ ffmpeg -i in.mp3 -acodec copy -y out.mp3
also makes the resulting files having gaps.
The back story is that bs1770gain apparently somehow uses ffmpeg.

And the answer is yes, after copying the files as above with ffmpeg,
they have gaps when played back.

So apart from the fact that I wonder why ffmpeg is used here at all
(shouldn't just some ID3 tags or that like be written?), it may be an
issue in ffmpeg.


btw: Using ffmpeg, even in copy mode seems to have other issues as
well:
ffmpeg version 2.7.2-2+b1 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.1 (Debian 5.2.1-15) 20150808
  configuration: --prefix=/usr --extra-version=2+b1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libx264 --enable-libopencv --enable-libx265
  WARNING: library configuration mismatch
  avcodec     configuration: --prefix=/usr --extra-version=2+b1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --enable-shared --disable-stripping --enable-avresample --enable-avisynth --enable-frei0r --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-openal --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libxvid --enable-libzvbi --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-libssh --enable-libx264 --enable-libopencv --enable-libx265 --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_aacenc --enable-libvo_amrwbenc
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
[mp3 @ 0x15a8e40] Skipping 0 bytes of junk at 417.
Input #0, mp3, from '2.mp3':
  Duration: 00:10:45.09, start: 0.025057, bitrate: 166 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 166 kb/s
    Metadata:
      encoder         : LAME3.99r
Output #0, mp3, to 'b.mp3':
  Metadata:
    TSSE            : Lavf56.36.100
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, 166 kb/s
    Metadata:
      encoder         : LAME3.99r
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp3 @ 0x15abba0] Audio packet of size 128 (starting with 54414700...) is invalid, writing it anyway.
size=   13141kB time=00:10:45.09 bitrate= 166.9kbits/s
video:0kB audio:13140kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.003872%



As one can see above here, there's an error that ffmpeg thinks
something would be invalid.
It seems to still write it here, but I'd guess that the copy mode is
still like a full parsing and freshly rewriting.
Sounds like an invitation for all kinds of things going wrong :-(


@Peter: Why exactly do you need to use ffmpeg for writing? Shouldn't it
be enough to write some tags?


Cheers,
Chris.

#797965#15
Date:
2015-09-05 14:23:35 UTC
From:
To:
Because bs1770gain is not supposed to have a myriad of backends to deal
with. It should be just one: FFmpeg.

The hope is that one day FFmpeg will have fixed their errors. They are
the experts for those myriads of formats and codecs.

Please file these errors under FFmpeg.

Thanks,

Peter

#797965#20
Date:
2015-09-10 18:32:51 UTC
From:
To:
[Peter Belkner]

This sound like a good argument for reassigning this bug report to
ffmpeg.  But I suspect the maintainers are going to need a way to
reproduce it.  Can you provide those details before we pass this bug
on to ffmpeg?

#797965#25
Date:
2015-09-14 18:03:07 UTC
From:
To:
ffmpeg -i <in.mp3> -acodec copy -y <out.mp3>

erases gapless.

Regards

#797965#30
Date:
2015-12-19 19:40:00 UTC
From:
To:
Control: reassign -1 libavformat-dev
Control: found -1 7:2.8.3-1
Control: affects -1 bs1770gain

As the bs1770gain developer Peter Belkner explain, this issue is
really an issue in ffmpeg and not in bs1770gain.  Because of this, I
reassign it to ffmpeg.

#797965#43
Date:
2015-12-19 19:47:09 UTC
From:
To:
Hi,

Can you provide a sample for reproducing this problem?

Best regards,
Andreas

#797965#50
Date:
2015-12-19 19:57:33 UTC
From:
To:
Well I think it's still also some kind of a design issue.

The problem is that ffmpeg, by nature a encoder/decoder, is always more
likely to actually change the different streams, than if the
application would just write to the respective meta-data/tags areas of
the file in question.

I also thought there would be quite a number of libs, which serve as a
more or less general purpose tagging lib.


Cheers,
Chris.

#797965#55
Date:
2015-12-19 19:59:03 UTC
From:
To:
Providing samples is always a bit problematic for copyrightreasons,
especially when providing them publicly.

Any CD-DA, which has gapless tracks (e.g. typically live CDs) will do.
If you don't have access to any, contact me off list.

Cheers,
Chris.

#797965#60
Date:
2015-12-19 19:59:57 UTC
From:
To:
Hi Peter,

I might be missing what the problem is, but this command seems to work
just fine with ffmpeg's test sample [1].
Can you confirm this, or describe more precisely what the problem is?

Best regards,
Andreas


1: https://fate-suite.ffmpeg.org/gapless/gapless.mp3

#797965#65
Date:
2015-12-19 20:05:24 UTC
From:
To:
Unless you can reproduce this with ffmpeg's test sample (in which
case, please elaborate what the problem is), please send my privately
(a link to) a small sample.

Best regards,
Andreas

#797965#70
Date:
2015-12-19 20:05:35 UTC
From:
To:
The problem is not mine but the one of Andreas Cadhalpun. You should
discuss it with him.

#797965#75
Date:
2015-12-19 20:08:37 UTC
From:
To:
I guess you wanted to say Christoph Anton Mitterer...

Best regards,
Andreas

#797965#80
Date:
2015-12-19 19:53:24 UTC
From:
To:
Any

    ffmpeg -i <in.mp3> -acodec copy -y <out.mp3>

should do it.

#797965#85
Date:
2015-12-19 20:09:51 UTC
From:
To:
You need two WAV files, which contain seamlessly playing sound (e.g.
just take any song and split it in the middle).

For lossless formats, there is typically no problem, that these two
play back again seamless (typically called "gapless").

When encoding them to lossy formats however, things get more tricky.
Different format provides for different means of gapless playback (or
none at all).
MP3 has e.g. two widespread ways, one by mean of LAME adding some
special tags, and itunes has something similar.
Opus/Vorbis/AAC, have similar things.

The problem was now, that when such gaplessly encoded files were
processed with bs1770gain, they were no longer gapless afterwards.

Peter thinks, due to a problem in the copy mode of ffmpeg.

If it's really that, and if you just do ffmpeg copy one one file, you
won't probably hear it... even when two audio files that belong
together, you may need to listen *very* closely to hear a gap.


Cheers,
Chris.

#797965#90
Date:
2015-12-19 20:18:39 UTC
From:
To:
Wait a few minutes...
#797965#95
Date:
2015-12-19 22:24:18 UTC
From:
To:
Hi,

OK, so the problem is that after remuxing with ffmpeg, there is
a barely audible ... gap ... between the two files, right?

Now I'm a bit skeptical about "LAME adding some special tags".
You've used lame with '--id3v2-utf16 --add-id3v2 --id3v1-only'.
What is this supposed to do? Add id3v1 tags, or id3v2 or both?

Additionally it seems the created files contain neither.
And leaving out these id3 options doesn't change the output
from lame.

So I'm not sure how this is supposed to work.

Best regards,
Andreas

#797965#106
Date:
2015-12-19 22:55:40 UTC
From:
To:
Yes
IIRC, the LAME tag isn't actually an ID3 tag, but padded in some other
parts of the MP3 header which aren't used.
http://gabriel.mp3-tech.org/mp3infotag.html
http://wiki.hydrogenaud.io/index.php?title=LAME#VBR_header_and_LAME_tag
http://libzplay.sourceforge.net/LAMETAG.html
IIRC the problem was that either bs1770gain but more likely python-
rgain (which I had to use in the end, because of the problem with
bs1770gain) didn't set any replay gain tags (which *are* in fact ID3
tags) at all, when no ID3 was present at all.

These options basically made, that both a ID3v1 and ID3v2 "section" was
created (the later with UTF16 encoding), however with no tags.
Hmm... maybe I did in addition set one dummy tag like --tc=' ', and
removed that afterwards.
What exactly now? The stuff with the tags? I guess you can ignore that,
since I've just had it in place for, IIRC, python-rgain,...

What I would assume that ffmpeg does, is, that it simply drops or
somehow mangles up the LAMEtag,... or actually modifies the audio
stream so that it doesn't fit to the LAMEtag anymore.


Cheers,
Chris.

#797965#111
Date:
2015-12-20 05:52:03 UTC
From:
To:
AFAIK it's the so called LAME or XING header. I myself was adding the
first version of it to FFmpeg some time ago but unfortunately not based
on my proposal (just copy it) but the way the FFmpeg team wants to have
it. Meanwhile it's changed anyway.

#797965#116
Date:
2015-12-22 22:43:18 UTC
From:
To:
Hi,

Thanks for this clarification. I was indeed confused by the ID3 tags
mentioned in the initial report.

Indeed, FFmpeg parses the XING/LAME header when demuxing and then
writes a new one when muxing.

Oh cool! What a coincidence!

Well, simply copying would have its problems, e.g. if it's actually
transcoded, the copied header would most likely be quite wrong...

On the other hand, parsing the header has its own problems, as this
bug shows: While the demuxer reads the correct gapless values from
the XING/LAME header, they are never propagated to the muxer and
not written to the output.

I've hacked together a patch[1] that makes this work, but don't get too
excited: It can't be committed as is, because it uses private
libavformat fields outside of libavformat.

Best regards,
Andreas


1: https://ffmpeg.org/pipermail/ffmpeg-devel/2015-December/185657.html

#797965#121
Date:
2016-03-25 20:43:56 UTC
From:
To:
Hi!

If I understand correctly, no sample and no command line including complete,
uncut console output was ever provided for this bug report.

If this is correct, please close as needs-more-information.

Thank you, Carl Eugen

#797965#126
Date:
2016-06-29 19:56:19 UTC
From:
To:
Hey.

Andreas, anything new on this? What happened to your proposed patch?

Carl:
- The command lines are given in the initial mail of this bug.
- IIRC a sample link was provided somewhere as well, but if that
  doesn't suit you, simply take *any* wav file on earth, split it in
  two halfs a a position with sound, encode the resulting files with
  e.g. lame, process it with bs1770gain (and thus ffmpeg) and then
  you'll see how the gapless information gets destroyed.
- As for logs, this is always a bit tedious,... I did provide such logs
  in other bugs I've opened at ffmpeg upstream about gapless playback
  issues, with never any clear outcome.
  Since ffmpeg has quite some development pace, any such logs would be
  useless few weeks after I've posted them.
  If a developer actually looks into that issue, I can of course
  provide such logs, but since this is a general bug, it's really very
  easy to create sample files and logs oneself. I'd say it doesn't take
  5 mins, and for an audio developer probably even less.


Cheers,
Chris.

#797965#131
Date:
2016-06-30 00:48:24 UTC
From:
To:
Hi!

If you want me to forward this bug to other FFmpeg developers, please:
* Provide sample(s) that allow to reproduce the issue
and
* The ffmpeg command line that allows to reproduce the issue together with
the complete, uncut console output
and
* explain what is wrong with the output file.

If you cannot (or don't want to) provide all three, I suggest to close
this bug because I don't see how it can be fixed without it.
(Or at least it wouldn't be known on this bug tracker if the issue ever
gets fixed.)

If the issue is not reproducible with the ffmpeg command line tool but
only for an API user, things get more complicated but in this case you
should try hard to rule out a bug in the tool using the API.

Carl Eugen

#797965#136
Date:
2016-06-30 07:07:16 UTC
From:
To:
[Mails to nnnnnn@bugs.debian.org do not reach the submitter. Explicitly CC-ing
Christoph]

#797965#141
Date:
2016-10-18 18:33:12 UTC
From:
To:
Hi Cris,

Jon Toohill managed to write a proper patch for this and it is now
fixed upstream [1].

Best regards,
Andreas


1: https://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=3b02f6dd7be880fd6c1bcaf2fd0c1314dcee7aa6

#797965#148
Date:
2016-10-22 21:24:16 UTC
From:
To:
tag 797965 pending
thanks

Hello,

Bug #797965 reported by you has been fixed in the Git repository. You can
see the changelog below, and you can check the diff of the fix at:

http://git.debian.org/?p=pkg-multimedia/ffmpeg.git;a=commitdiff;h=191ec5c

    Finalize changelog

diff --git a/debian/changelog b/debian/changelog
index 88975bb..8d57546 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,31 @@
+ffmpeg (7:3.1.5-1) unstable; urgency=medium
+
+  * Import new upstream bugfix release 3.1.5.
+  * Use nasm instead of yasm.
+    - Unlike yasm it is actively maintained upstream.
+    - And it doesn't embed the full build path as DW_AT_comp_dir.
+      (This should make ffmpeg fully reproducible.)
+  * Drop patches, fixed differently upstream:
+    - disable-opj-static.patch
+    - libopenjpegenc-recreate-image-data-buffer.patch
+  * Add patches from upstream:
+     - doc-fix-spelling-errors.patch (Closes: #839542)
+     - faq-use-relative-links-to-own-documentation.patch (Closes: #841501)
+     - ffmpeg_opt-Suggest-to-use-file-.-if-a-protocol-was-not-fo.patch
+       (Closes: #785690)
+     - lavf-mp3enc-write-encoder-delay-padding-upon-closing.patch
+       (Closes: #797965)
+     - tests-checkasm-pixblockdsp-Test-8-byte-aligned-positions.patch
+       (LP: #1612058)
+  * Use debhelper compat 10.
+     - Parallel building is now the default.
+  * Revert: Enable all hardening options except pie.
+     - It doesn't have any effect, anyway.
+     - PIE is now the default.
+  * Adapt lintian overrides to PIE by default.
+
+ -- Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>  Sat, 22 Oct 2016 22:33:02 +0200
+
 ffmpeg (7:3.1.4-1) unstable; urgency=medium

   [ Ondřej Nový ]

#797965#153
Date:
2016-10-23 21:11:29 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
ffmpeg, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 797965@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> (supplier of updated ffmpeg package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Sat, 22 Oct 2016 22:33:02 +0200
Source: ffmpeg
Binary: ffmpeg ffmpeg-doc libavcodec57 libavcodec-extra57 libavcodec-extra libavcodec-dev libavdevice57 libavdevice-dev libavfilter6 libavfilter-extra6 libavfilter-extra libavfilter-dev libavformat57 libavformat-dev libavresample3 libavresample-dev libavutil55 libavutil-dev libpostproc54 libpostproc-dev libswresample2 libswresample-dev libswscale4 libswscale-dev libav-tools
Architecture: source
Version: 7:3.1.5-1
Distribution: unstable
Urgency: medium
Maintainer: Debian Multimedia Maintainers <pkg-multimedia-maintainers@lists.alioth.debian.org>
Changed-By: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Description:
 ffmpeg     - Tools for transcoding, streaming and playing of multimedia files
 ffmpeg-doc - Documentation of the FFmpeg multimedia framework
 libav-tools - Compatibility links for libav-tools (transitional package)
 libavcodec-dev - FFmpeg library with de/encoders for audio/video codecs - developm
 libavcodec-extra - FFmpeg library with extra codecs (metapackage)
 libavcodec-extra57 - FFmpeg library with additional de/encoders for audio/video codecs
 libavcodec57 - FFmpeg library with de/encoders for audio/video codecs - runtime
 libavdevice-dev - FFmpeg library for handling input and output devices - developmen
 libavdevice57 - FFmpeg library for handling input and output devices - runtime fi
 libavfilter-dev - FFmpeg library containing media filters - development files
 libavfilter-extra - FFmpeg library with extra filters (metapackage)
 libavfilter-extra6 - FFmpeg library with extra media filters - runtime files
 libavfilter6 - FFmpeg library containing media filters - runtime files
 libavformat-dev - FFmpeg library with (de)muxers for multimedia containers - develo
 libavformat57 - FFmpeg library with (de)muxers for multimedia containers - runtim
 libavresample-dev - FFmpeg compatibility library for resampling - development files
 libavresample3 - FFmpeg compatibility library for resampling - runtime files
 libavutil-dev - FFmpeg library with functions for simplifying programming - devel
 libavutil55 - FFmpeg library with functions for simplifying programming - runti
 libpostproc-dev - FFmpeg library for post processing - development files
 libpostproc54 - FFmpeg library for post processing - runtime files
 libswresample-dev - FFmpeg library for audio resampling, rematrixing etc. - developme
 libswresample2 - FFmpeg library for audio resampling, rematrixing etc. - runtime f
 libswscale-dev - FFmpeg library for image scaling and various conversions - develo
 libswscale4 - FFmpeg library for image scaling and various conversions - runtim
Closes: 785690 797965 839542 841501
Changes:
 ffmpeg (7:3.1.5-1) unstable; urgency=medium
 .
   * Import new upstream bugfix release 3.1.5.
   * Use nasm instead of yasm.
     - Unlike yasm it is actively maintained upstream.
     - And it doesn't embed the full build path as DW_AT_comp_dir.
       (This should make ffmpeg fully reproducible.)
   * Drop patches, fixed differently upstream:
     - disable-opj-static.patch
     - libopenjpegenc-recreate-image-data-buffer.patch
   * Add patches from upstream:
      - doc-fix-spelling-errors.patch (Closes: #839542)
      - faq-use-relative-links-to-own-documentation.patch (Closes: #841501)
      - ffmpeg_opt-Suggest-to-use-file-.-if-a-protocol-was-not-fo.patch
        (Closes: #785690)
      - lavf-mp3enc-write-encoder-delay-padding-upon-closing.patch
        (Closes: #797965)
      - tests-checkasm-pixblockdsp-Test-8-byte-aligned-positions.patch
        (LP: #1612058)
   * Use debhelper compat 10.
      - Parallel building is now the default.
   * Revert: Enable all hardening options except pie.
      - It doesn't have any effect, anyway.
      - PIE is now the default.
   * Adapt lintian overrides to PIE by default.
Checksums-Sha1:
 716ef7e4cea53629923178c002490be8ad8c11cb 4734 ffmpeg_3.1.5-1.dsc
 dc3e61f41ef9c58ec79558cf390cf9e026dde807 7813540 ffmpeg_3.1.5.orig.tar.xz
 ecb71479772e47acb22adfb2e59cb8a62c73a457 42684 ffmpeg_3.1.5-1.debian.tar.xz
Checksums-Sha256:
 5f0cfb600cc1dce2185edec1d49f2bb8ffbad62b3d45af2bb69d40f320acbeb7 4734 ffmpeg_3.1.5-1.dsc
 49cc3105f7891c5637f8fabb1b75ebb19c9b5123b311a3ccc6182aa35d58b89a 7813540 ffmpeg_3.1.5.orig.tar.xz
 c1a559037a8962dfa47fe20ecbb11d8ec4c7194ff1db3e01bcd714a956b94a89 42684 ffmpeg_3.1.5-1.debian.tar.xz
Files:
 5cc4689e765a08cf33679e83ee104433 4734 video optional ffmpeg_3.1.5-1.dsc
 a09f7730ceeb665c6f7da0b884dd00f9 7813540 video optional ffmpeg_3.1.5.orig.tar.xz
 c27d921f80d7a59698aafee420a53687 42684 video optional ffmpeg_3.1.5-1.debian.tar.xz
iQIcBAEBCAAGBQJYDMNKAAoJEPZk0la0aRp9tyUP/ixqQKrUs9trXlCiIHFdKUp0
AOv1QWgQPPa/ewr1e9lZvJOVkcN2kCgPYce+TGg39doPQFOiyfojLg+y7wihgPQx
HueOjgejLt4tq5y5wxoWkKkfkklibfD3szustcKYLzJDTG5dnkR96EC/EjZRkgFR
ZzgniQ5qH0+hI9T/HexdTBq7MiBmC8MdWOj4SXx1XTxQ+f12YmESTL3bAyAQFGBI
SnhSf35kCHoYU6b3gNE3K8+wBzmP57xe/V21xFELrEbgdtnl0kX1zk8+OBUcHxZA
w5/A0x5+qNdqi2eA58sVClSW1O/GM/uehVhW18qXhWXxRPKZQl4x88yL54Aa19Y5
WSYZ71xSHFrcWuH0EMtkHq2WmtW6Rl/uM8WPjCCbXvGtDbcosEbuH3Vu3PBZHz3V
gdadWKWZB/dKXPdcnV3bTGW+436jI5hbrdqwhv1JxUqBWNlmgBaImT6tg4IyTllk
w0rscZl77q5mQNBdUU5k1DhcA90xYPqgAgxtgvh64jUdmgBCOB+k5MX2aZMp8++q
EUmKahmuVeBR00btJn+s1xzKWbyvxHe8dA6HO0TEYh+6/nuT37Z2kLvGfBpRWTY6
iTLATZLwXnxnAZdbNnKg5FDSDoRVn5RcWCQYgtwCrEVR9ntlAFHiZVjiWlCg57UL
V6VO0DAtFPW33tk3eCR5
=HwyM
-----END PGP SIGNATURE-----

#797965#166
Date:
2019-04-04 00:59:15 UTC
From:
To:
Hey Andreas.

I'm afraid I have to reopen this.

Today I made a fresh set of extensive checks for gapless playback in
mpv (from Debian sid with the ffmpeg from sid) and also upstream git
master HEAD ffmpeg alone.

The details results can be found here:
https://trac.ffmpeg.org/ticket/7828#comment:2
https://github.com/mpv-player/mpv/issues/2284#issuecomment-479667296

Long story short:
In mpv MP3/Opus play gapless quite fine.
In ffmpeg, it works at least with the version from git (but not with
the one in Debian); reasons seems to be an issue in the ffmpeg(1)
program itself which was recently fixed... while mpv used the libs
already correctly.


From that I'd have expected that bs1770gain also works now and files
that have been processed by it still play back gaplessly, however it
does not.



1) First pair of test files
From the test-files from the two bug reports above I used:
02.split-track01.mp3
02.split-track02.mp3

and

03.split-track01.opus
03.split-track02.opus

each of them in a directory, which I then processed (each dir) with:
bs1770gain dir -t -o outdir

Playing these with:
mpv 02.split-track01.mp3 02.split-track02.mp3
respectively
mpv 03.split-track01.opus 03.split-track02.opus
works without any gap/distortion.


Fine so far, but now...




2) Second pair of test files
I do have another pair of sample file from an audio CD.
Encoded them exactly as described in the ffmpeg/mpv tickets with lame
respectively opusenc.
Processed them as above with bs1770gain (the Debian version from sid,
with the ffmpeg version from sid).

With the (bs1770gain processed) MP3 files, there is a
distortion/corruption at the the intersection, which I can clearly
hear.
However... the (bs1770gain processed) Opus files are fine!!! (wtf?)


It can also be seen in the waveform (see attached images):
For that I decoded the files with lame --decode respectively opusdec
(not with ffmpeg this time), joined each pair together with sox and
displayed them in sonic-visualizer with:


top:
the sox concatenation of the original two WAV sample files

middle:
the joined WAVs decoded from the MP3 respectively Opus

bottom:
just the WAV of first track from MP3 respectively Opus, serving just as
reference as to where the intersection is




Any idea why the MP3 is still mangled up? It apparently seems to depend
on the input file... so maybe it's just luck, that the Opus worked
here.


Thanks,
Chris.

btw: As for the sample files, I wouldn't want to upload them publicly
since these are from some copyrighted Audio CD,... but I can make them
privately available to some developers if this is desired.

#797965#175
Date:
2020-02-13 20:31:43 UTC
From:
To:

#797965#180
Date:
2020-02-20 04:00:47 UTC
From:
To:
Any further ideas on this?

I've just checked again with the current ffmpeg/bs1770gain versions
from sid... and still, the gapless playback of MP3s is broken when
files are processed with --overwrite.

It does seem to work when not using --overwrite mode (but -a -o
dir),... but that's no big surprise as files are decoded to flac (which
is per se gapless), but this is probably not what most people want.


Seems a bit as if something is going wrong when the mp3 stream is
remuxed or stored again.


With the unfortunate removal of python-rgain, bs1770gain seems to be
the only remaining replaygain tool in Debian... so it would be really
nice if ffmpeg could be made no breaking the output files :-)


Cheers,
Chris.

#797965#185
Date:
2020-02-20 04:12:50 UTC
From:
To:
Oh an one further thing... doing:
ffmpeg -i in.mp3 -acodec copy -y out.mp3

with both files (i.e. those that should playback gapless) also destroys
the gabless playback, that worked just perfectly fine with the files
straight from lame.


Cheers,
Chris.

#797965#190
Date:
2020-02-24 02:06:31 UTC
From:
To:

#797965#197
Date:
2022-04-29 02:43:32 UTC
From:
To:
Hey there.

I just retried that again, both:
- with bs1770gain and
- with plain ffmpeg -i in.mp3 -acodec copy -y out.mp3


and it seems that this must have been fixed at some point in ffmpeg.

Gapless playback is at least preserved for MP3 and Opus (didn't check
other formats).

This requires of course the use of bs1770gain’s --codec and --suffix
options, otherwise stuff would be converted to FLAC in an MKV
container.

Also, when using these options to get the same codec/container, ffmpeg
seems to really copy the encoded audio stream.

The files may still differ (even with plain ffmpeg copy) because ffmpeg
seems to add it's own meta data for some reason.



Anyway, this should be fixed, thus closing.

Thanks,
Chris.

#797965#202
Date:
2022-04-29 03:09:31 UTC
From:
To:
Sorry... I had taken other files in my tests before, than what I've
used back then.


I dug out those now and re-checked again with them.. and while it does
work for them with Opus.. it doesn't with MP3.

So there's still something in ffmpeg, which destroys the gappless
playback, on some files at least, when these are just copied.

Cheers,
Chris.