Bug 322107 - Amarok creates MP3 invalid files with bitrate above 320 Kbps
Summary: Amarok creates MP3 invalid files with bitrate above 320 Kbps
Status: CONFIRMED
Alias: None
Product: amarok
Classification: Applications
Component: Transcoding (show other bugs)
Version: 2.7.1
Platform: Other Linux
: NOR normal
Target Milestone: 2.8
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-08 10:05 UTC by Paulo Fidalgo
Modified: 2024-07-29 10:22 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paulo Fidalgo 2013-07-08 10:05:56 UTC
I have some FLAC files in my collection and since my car can read files I need to transcode them to MP3. Although with the current version of amarok, the create files have peaks with bitrate higher than 320kbps (has the specs say, this is the maximum allowed bitrate), so my car fails to read them.

Since amarok uses ffmpeg to transcode you may need to pass a maximum bitrate parameter to ensure the files are valid.

Even with the 175Kbps level the resulting files have peaks higher than 320Kbps. When i use lame encoder, even in the higher profile the files play pretty decent,

Reproducible: Always
Comment 1 Matěj Laitl 2013-07-12 14:03:40 UTC
(In reply to comment #0)
> I have some FLAC files in my collection and since my car can read files I
> need to transcode them to MP3. Although with the current version of amarok,
> the create files have peaks with bitrate higher than 320kbps (has the specs
> say, this is the maximum allowed bitrate), so my car fails to read them.

I see.

> Since amarok uses ffmpeg to transcode you may need to pass a maximum bitrate
> parameter to ensure the files are valid.

Oh, do you know of some specific command-line arg to do this? We'd like to support both original ffmpeg and libav's ffmpeg compatibility wrapper. Can you check that both of these support the option?

If you're brave enough and modify the passed arguments [Mp3Format::ffmpegParameters() in src/core/transcoding/formats/TranscodingMp3Format.cpp], do the tracks play in your car?

> Even with the 175Kbps level the resulting files have peaks higher than
> 320Kbps. When i use lame encoder, even in the higher profile the files play
> pretty decent,

Interesting Amarok actually uses lame (through ffmpeg), but perhaps ffmpeg uses liblame differently that it is used by the lame command-line tool.
Comment 2 Myriam Schweingruber 2014-08-12 10:50:41 UTC
Any news on this?
Comment 3 Paulo Fidalgo 2014-08-19 08:06:24 UTC
I'm still experience this. I've tried to find a way to get every frame's bitrate, but I can't find any tool. The only way I've got is to look in VLC codec statistics and see if the value goes beyond 320kbps.
Comment 4 Myriam Schweingruber 2014-08-19 10:48:47 UTC
Then could you please answer the questions from comment #1?
Comment 5 Paulo Fidalgo 2014-08-19 11:09:42 UTC
(In reply to Matěj Laitl from comment #1)
> (In reply to comment #0)
> > I have some FLAC files in my collection and since my car can read files I
> > need to transcode them to MP3. Although with the current version of amarok,
> > the create files have peaks with bitrate higher than 320kbps (has the specs
> > say, this is the maximum allowed bitrate), so my car fails to read them.
> 
> I see.
> 
> > Since amarok uses ffmpeg to transcode you may need to pass a maximum bitrate
> > parameter to ensure the files are valid.
> 
> Oh, do you know of some specific command-line arg to do this? We'd like to
> support both original ffmpeg and libav's ffmpeg compatibility wrapper. Can
> you check that both of these support the option?

No, even after reading the documentation: https://trac.ffmpeg.org/wiki/Encode/MP3 I can't found a way to limit it. 

> 
> If you're brave enough and modify the passed arguments
> [Mp3Format::ffmpegParameters() in
> src/core/transcoding/formats/TranscodingMp3Format.cpp], do the tracks play
> in your car?
> 
> > Even with the 175Kbps level the resulting files have peaks higher than
> > 320Kbps. When i use lame encoder, even in the higher profile the files play
> > pretty decent,
> 
> Interesting Amarok actually uses lame (through ffmpeg), but perhaps ffmpeg
> uses liblame differently that it is used by the lame command-line tool.

I will try to find a way to print the information... and check if I can get the information via VLC. If somebody knows any script or program for analysing the mp3 and check the bitrate please let me know.

NOTE: this seems to be a bug in ffmepg, not in Amarok, but I'm still trying to find the source of the problem.
Comment 6 Paulo Fidalgo 2014-10-23 17:20:05 UTC
I've opened a bug on FFMPEG bug tracking... and I'm awaiting for developers comments.
https://trac.ffmpeg.org/ticket/4055

If anybody want to leave a comment, with more details or questions, please do, so the developers could give more attention to the issue.
Comment 7 Paulo Fidalgo 2014-11-10 19:31:59 UTC
I've sorted the problem, but the I can only get it working in a recent ffmpeg version,

That behaviour is caused by Xing Headers, so disabling it with "-write_xing 0" parameter I can play the audio files normally. You can see more information about it here: https://ffmpeg.org/ffmpeg-formats.html#mp3

So regarding amarok, the only way to get this properly solved is to allow changing the parameters of the encoder or if make sense use that parameter permanently.
Comment 8 Myriam Schweingruber 2014-11-11 06:52:29 UTC
(In reply to Paulo Fidalgo from comment #7)
> I've sorted the problem, but the I can only get it working in a recent
> ffmpeg version,
> 
> That behaviour is caused by Xing Headers, so disabling it with "-write_xing
> 0" parameter I can play the audio files normally. You can see more
> information about it here: https://ffmpeg.org/ffmpeg-formats.html#mp3
> 
> So regarding amarok, the only way to get this properly solved is to allow
> changing the parameters of the encoder or if make sense use that parameter
> permanently.

Thanks a lot for your research, now we have a good hint on how to solve the issue.
Comment 9 robert marshall 2024-05-25 08:01:11 UTC
This bug is still present (in 3.0.0-git) - I tried transcoding some flac files to mp3 at 175Kbps, the mp3s were created but they are unplayable - and the transcode removes the originals :(
Comment 10 Tuomas Nurmi 2024-06-02 09:28:03 UTC
I tried adding
parameters << QStringLiteral("-write_xing") << QStringLiteral("0"); 
to Mp3Format::ffmpegParameters() and although I can observe some differences in tracks transcoded with and without that parameter, I haven't yet found a way to measure what is the maximal bitrate. Any hints welcome.

"and the transcode removes the originals"
sounds strange, doesn't happen here when I'm doing the transcoding via "Copy to Collection"; the original remains in place
Comment 11 robert marshall 2024-07-29 10:22:06 UTC
"and the transcode removes the originals" - no that was my own fault - I removed the originals - should have checked the transcode was ok first!