[FFmpeg-devel] [PATCH 1/2] lavf/mp3dec: pass Xing gapless metadata to AVCodecParameters

Michael Niedermayer michael at niedermayer.cc
Mon Jun 13 04:31:44 CEST 2016


On Wed, Jun 08, 2016 at 10:46:49AM -0700, Jon Toohill wrote:
> Michael et al., is this good to merge as-is? I just tested and a round trip
> with ffmpeg from wav -> mp3 -> wav retains the correct number of samples.

There seems to be a inconsistency 

try the patch below with your patch, and write a mp3 file with ffmpeg
and the read it the initial_padding is not what was written

or try this:
/ffmpeg -i test.mp3 -codec copy test2.mp3
read padding 576
written padding 576

./ffmpeg -i test2.mp3 -codec copy test3.mp3
read padding 47
written padding 47


diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 345fa88..b063ad9 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -240,6 +240,7 @@ static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st,
         mp3->start_pad = v>>12;
         mp3->  end_pad = v&4095;
         st->codecpar->initial_padding = mp3->start_pad;
+        av_log(0,0, "read padding %d\n", st->codecpar->initial_padding );
         st->codecpar->trailing_padding = mp3->end_pad;
         st->start_skip_samples = mp3->start_pad + 528 + 1;
         if (mp3->frames) {
diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index de63401..a971136 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -253,7 +253,7 @@ static int mp3_write_xing(AVFormatContext *s)
         av_log(s, AV_LOG_WARNING, "Too many samples of initial padding.\n");
     }
     avio_wb24(dyn_ctx, FFMAX(par->initial_padding - 528 - 1, 0)<<12);
-
+av_log(0,0, "written padding %d\n", par->initial_padding );
     avio_w8(dyn_ctx,   0); // misc
     avio_w8(dyn_ctx,   0); // mp3gain
     avio_wb16(dyn_ctx, 0); // preset

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160613/2d9e067c/attachment.sig>


More information about the ffmpeg-devel mailing list