Concat mp3 files into one large file without encoding?

Post tutorials, HOWTO's and other useful resources here.
User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Concat mp3 files into one large file without encoding?

Post#1 by Rava » 16 Feb 2022, 04:06

Is there a way to concat mp3 files into one large mp3 file?

E.g. using ffmpeg.

The reason: some Audio CDs have continuous songs without any breaks in between them. E.g. Enigma - Cross of Changes. The short breaks you get when listening to it via its single files is annoying… since I own the Audio CD of the example I could simple rip it again using cdparanoia parameter to write it all into one wav file (I vaguely recall there exists such parameter)

But I wonder if merging the already existing files without decoding and re-encoding would also work?

Audacious has almost no break between these files, but my ffplay solution (via my make-ffplay-script V3.48) cannot since it needs to start a new ffplay instance. :(
Cheers!
Yours Rava

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3933
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

Concat mp3 files into one large file without encoding?

Post#2 by ncmprhnsbl » 16 Feb 2022, 06:11

according to here: https://bytefreaks.net/applications/how ... ing-ffmpeg

Code: Select all

ffmpeg -i "concat:20181021_080743.MP3|20181021_090745.MP3|20181021_100745.MP3" -acodec copy 20181021.mp3
and here: https://stackoverflow.com/questions/477 ... g#47747118
slightly differently:

Code: Select all

ffmpeg -f concat -i list.txt -c copy merged.mp3
where, i guess, list.txt is a list of the mp3s to be merged..

more: https://trac.ffmpeg.org/wiki/Concatenate#protocol
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
M. Eerie
Moderator
Moderator
Posts: 622
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

Concat mp3 files into one large file without encoding?

Post#3 by M. Eerie » 16 Feb 2022, 08:31

If you want to concatenate files, firstly you want to ensure they are "coherent" --> They all have same bitrate, number of channels and sampling rate)

Example list.txt:
file input1.mp3
file input2.mp3
file input3.mp3
...

Where input1, input2 and input3 are *all* 128kpbs 2 channels at 44Khz sampling rate (typical CD's values)
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Concat mp3 files into one large file without encoding?

Post#4 by Rava » 16 Feb 2022, 09:22

Thanks ncmprhnsbl and M. Eerie,
M. Eerie wrote:
16 Feb 2022, 08:31
If you want to concatenate files, firstly you want to ensure they are "coherent" --> They all have same bitrate, number of channels and sampling rate)
since I ripped and encoded them myself they all should have the same number of channels and sampling rate.
I try it later and report back. The
file input1.mp3
file input2.mp3
created some issues in the past how it handles whitespace, but somewhere should be a readme I made about it…
Cheers!
Yours Rava

beny
Full of knowledge
Full of knowledge
Posts: 2092
Joined: 02 Jan 2011, 11:33
Location: italy

Concat mp3 files into one large file without encoding?

Post#5 by beny » 17 Feb 2022, 11:29

hi someone can try this if work: bash-5.1# cat *.mp3 > mylist.mp3, terminal into the directory, audacious show the title of the track list merged.

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Concat mp3 files into one large file without encoding?

Post#6 by Rava » 17 Feb 2022, 11:50

Rava wrote:
16 Feb 2022, 09:22
created some issues in the past how it handles whitespace, but somewhere should be a readme I made about it…
found it: it is here, even with screenshot and detailed explanation how to handle the white spaces and
" ' " :
[Info] ffmpeg encoding (Post by Rava #83704)
Seems the white spaces are less of an issue, the issue was how to handle file names with single quotes aka ' …
Cheers!
Yours Rava

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Concat mp3 files into one large file without encoding?

Post#7 by Rava » 17 Feb 2022, 12:49

Since I use both whitespace and ' I had to escape the ' and use -safe 0:
The concat.txt

Code: Select all

file 'Cross of Changes--01--Second Chapter.mp3'
file 'Cross of Changes--02--Eyes of truth.mp3'
file 'Cross of Changes--03--Return to innocence.mp3'
file 'Cross of Changes--04--I love you... I'\''ll kill you.mp3'
file 'Cross of Changes--06--Dream of the Dolphin.mp3'
file 'Cross of Changes--07--Age of loneliness -Carlys song.mp3'
file 'Cross of Changes--08--Out of the deep.mp3'
file 'Cross of Changes--09--Cross of Changes.mp3'
the command used:

Code: Select all

ffmpeg -v error -safe 0 -f concat -i concat.txt -c copy Cross\ of\ Changes.mp3
Sadly, it gives quite some errors or warnings like this

Code: Select all

mp3 @ 0x1848e00] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 94198765 >= 94188916
and when switching at the time stamp where the new file should begin mpv gives an error and there is an audible pause due to the error:

Code: Select all

guest@porteus:/mysound/blues+rock+pop/Enigma$ mpv Cross\ of\ Changes.mp3 
 (+) Audio --aid=1 (mp3 2ch 44100Hz)
AO: [pulse] 44100Hz stereo 2ch float
A: 00:02:15 / 00:38:04 (6%)
[ffmpeg/audio] mp3float: Header missing
Error decoding audio.
A: 00:02:27 / 00:38:04 (6%)

Exiting... (Quit)
And here the transition moment error in ffplay:

Code: Select all

guest@porteus:/mysound/blues+rock+pop/Enigma$ ffplay Cross\ of\ Changes.mp3 
[mp3 @ 0x7f2f08000c80] Skipping 2048 bytes of junk at 462.B f=0/0   
Input #0, mp3, from 'Cross of Changes.mp3':
  Metadata:
    encoder         : Lavf58.76.100
  Duration: 00:38:04.70, start: 0.011995, bitrate: 127 kb/s
  Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 127 kb/s
    Metadata:
      encoder         : Lavf
[mp3float @ 0x7f2f080068c0] Header missing    0KB sq=    0B f=0/0   
 139.06 M-A: -0.000 fd=   0 aq=   16KB vq=    0KB sq=    0B f=0/0   
The files that are merged at that point are:

Code: Select all

Cross of Changes--01--Second Chapter.mp3
Cross of Changes--02--Eyes of truth.mp3
ffprope says about these:

Code: Select all

guest@porteus:/mysound/blues+rock+pop/Enigma$ ffprobe Cross\ of\ Changes--01--Second\ Chapter.mp3 
[wav @ 0x1406400] ignoring wrong sample_count 51971
[mp3float @ 0x1409140] Header missing
[wav @ 0x1406400] Estimating duration from bitrate, this may be inaccurate
Input #0, wav, from 'Cross of Changes--01--Second Chapter.mp3':
  Metadata:
    artist          : Enigma
    title           : mea culpa
    track           : 4
    genre           : Fusion
    album           : Cross of Changes
    date            : 1993
  Duration: 00:02:14.42, bitrate: 128 kb/s
  Stream #0:0: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, fltp, 128 kb/s
guest@porteus:/mysound/blues+rock+pop/Enigma$ ffprobe Cross\ of\ Changes--02--Eyes\ of\ truth.mp3 
[wav @ 0xd78400] ignoring wrong sample_count 223146
[mp3float @ 0xd7b340] Header missing
[wav @ 0xd78400] Estimating duration from bitrate, this may be inaccurate
Input #0, wav, from 'Cross of Changes--02--Eyes of truth.mp3':
  Metadata:
    artist          : Enigma
    title           : mea culpa
    track           : 4
    genre           : Fusion
    album           : Cross of Changes
    date            : 1993
  Duration: 00:07:13.71, bitrate: 128 kb/s
  Stream #0:0: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, fltp, 128 kb/s
As you can see, both are 44100 Hz, stereo, fltp, 128 kb/s

If so, then why did it fail? Why the error when decoding? Image
Could the "ignoring wrong sample_count" and "Header missing" be the issue?
If so, how to fix that?

Added in 13 minutes 25 seconds:
Maybe "MP3 Diags" is the solution for my issue, currently reading https://www.ghacks.net/2009/11/24/use-m ... ollection/

Added in 11 minutes 26 seconds:
unfortunately mp3diag has quite the dependencies missing

Code: Select all

$ ldd /usr/bin/mp3diags |grep not
	libboost_serialization.so.1.66.0 => not found
	libboost_program_options.so.1.66.0 => not found
	libQt5Widgets.so.5 => not found
	libQt5Gui.so.5 => not found
	libQt5Xml.so.5 => not found
	libQt5Core.so.5 => not found
Postponing it for now…

The recent mp3diag I found was this:
https://ftp.lysator.liu.se/pub/opensuse ... x86_64.rpm
No mp3diag found for Slackware-current :(

Added in 7 minutes 12 seconds:
Hopefully these work and are enough:

Code: Select all

libQt5Core5-5.12.7-4.12.2.x86_64.rpm
libQt5Gui5-5.12.7-4.12.2.x86_64.rpm
libQt5Widgets5-5.12.7-4.12.2.x86_64.rpm
libQt5Xml5-5.12.7-4.12.2.x86_64.rpm
libboost_program_options1_66_0-1.66.0-10.1.x86_64.rpm
libboost_serialization1_66_0-1.66.0-10.1.x86_64.rpm
Added in 3 minutes 23 seconds:
Or maybe these since the files are both newer than the non-legacy ones above…
libboost_program_options_legacy-1.66.0-1.4.1.x86_64.rpm
libboost_serialization_legacy-1.66.0-1.4.1.x86_64.rpm
Cheers!
Yours Rava

beny
Full of knowledge
Full of knowledge
Posts: 2092
Joined: 02 Jan 2011, 11:33
Location: italy

Concat mp3 files into one large file without encoding?

Post#8 by beny » 17 Feb 2022, 17:57

hi slackware have the /mnt/sdk1/porteus/modules/MP3Diags-1.2.03-x86_64-2ponce.xzm and need only the qt4 to work on porteus,ok but mine is not stock now...

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Concat mp3 files into one large file without encoding?

Post#9 by Rava » 18 Feb 2022, 00:51

beny wrote:
17 Feb 2022, 17:57
hi slackware have the /mnt/sdk1/porteus/modules/MP3Diags-1.2.03-x86_64-2ponce.xzm and need only the qt4 to work on porteus,ok but mine is not stock now...
Do you have the URL?

I only found mp3diags-1.5.02-x86_64-2cf.txz via https://slack.conraid.net/repository/sl ... 64-2cf.txz and that has only the app /usr/bin/MP3Diags-unstable :

Code: Select all

guest@porteus:~$ ldd /usr/bin/MP3Diags-unstable |grep not
	libboost_serialization.so.1.78.0 => not found
	libQt5Widgets.so.5 => not found
	libQt5Gui.so.5 => not found
	libQt5Xml.so.5 => not found
	libQt5Network.so.5 => not found
	libQt5Core.so.5 => not found
Not that much difference when it comes to https://ftp.lysator.liu.se/pub/opensuse ... x86_64.rpm , only libboost_program_options.so.1.66.0 is missing as dependency, but instead it also needs libQt5Network.so.5 …

Added in 6 minutes 58 seconds:
I wonder, is there already a libQt bundle module in existence?
Seems at least I do not have one (that's to be found via

Code: Select all

find /mnt/sd* -iname "*libQt*" | grep -i xzm$
…) :(
Cheers!
Yours Rava

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3933
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

Concat mp3 files into one large file without encoding?

Post#10 by ncmprhnsbl » 18 Feb 2022, 05:58

Rava wrote:
18 Feb 2022, 00:58
I wonder, is there already a libQt bundle module in existence?

Code: Select all

root@porteus:/home/guest# bundles
.........
6) qt5-base-5.15.2-x86_64_10-xfce-cinnamon-openbox-lxde-mate.xzm
..........
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Concat mp3 files into one large file without encoding?

Post#11 by Rava » 18 Feb 2022, 10:21

^
Thanks, downloaded… will test later, first comes getting eye3D running, see other thread…

Added in 9 minutes 11 seconds:
Created MP3Diags-1.2.03-x86_64-2ponce.xzm
activated MP3Diags-1.2.03-x86_64-2ponce.xzm and qt5-base-5.15.2-x86_64_10-xfce-cinnamon-openbox-lxde-mate.xzm
Seems qt5-base-5.15.2-x86_64 is missing at least one library:

Code: Select all

guest@porteus:~$ ldd /usr/bin/MP3Diags |grep not
	libboost_serialization.so.1.78.0 => not found
	libQtXml.so.4 => not found
:(
Cheers!
Yours Rava

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Concat mp3 files into one large file without encoding?

Post#12 by Rava » 18 Feb 2022, 14:28

Finally got it running on XFCE 4.12 5.0rc3.

To get MP3Diags-1.2.03-x86_64-2ponce.xzm running you need
● creating the module out of MP3Diags-1.2.03-x86_64-2ponce.tgz
● qt5-base-5.15.2-x86_64_10-xfce-cinnamon-openbox-lxde-mate.xzm via bundles when your DE is xfce, cinnamon, openbox, lxde or mate.

● libboost_serialization.so.1.78.0.xzm that I extracted from boost-1.78.0-x86_64-1.txz (that package is 10.69 MB, while the libboost_serialization.so.1.78.0.xzm is only 60 KB)

● also, as root, do this dirty hack:

Code: Select all

cd /usr/lib64
ln -s libQt5Xml.so.5.15.2 libQtXml.so.4
And finally, MP3Diags-1.2.03-x86_64 is running.

Cave, the binary is not named mp3diags but instead MP3Diags if you want to start it from a terminal…

For now, the libQt5Xml.so.5.15.2 to libQtXml.so.4 hack seems to not affect the program… but it is only scanning the files and folders for now, not doing any work on any issues. (Since there are lots of files to scan it could take a while longer…)

If you want me uploading MP3Diags-1.2.03-x86_64-2ponce.xzm and libboost_serialization.so.1.78.0.xzm please tell me so.

Added in 41 minutes 54 seconds:
Update
While it looks like it runs okay, the icons at the top have no graphics, they are all just empty boxes. You have to hover with your mouse over one icon to let the popup info telling you what that icon is about.
For now I have no idea what is missing or how to fix the icon issue.
Cheers!
Yours Rava

User avatar
M. Eerie
Moderator
Moderator
Posts: 622
Joined: 31 Aug 2017, 21:18
Distribution: Nemesis Xfce/MATE x64

Concat mp3 files into one large file without encoding?

Post#13 by M. Eerie » 01 Mar 2022, 09:10

Rava wrote:
16 Feb 2022, 09:22
since I ripped and encoded them myself they all should have the same number of channels and sampling rate
Did you create them with variable bit rate (vbr) / average bit rate (abr) perchance?
If so, you could try to rip them again with constant bit rate (cbr) and then concatenate.
> Does not compute_ 🖖

https://forum.porteus.org/viewtopic.php?p=94310#p94310
https://forum.porteus.org/viewtopic.php?p=84002#p84002
https://forum.porteus.org/viewtopic.php?p=77174#p77174
https://forum.porteus.org/viewtopic.php?f=39&t=8584

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Concat mp3 files into one large file without encoding?

Post#14 by Rava » 08 Apr 2022, 00:02

M. Eerie wrote:
01 Mar 2022, 09:10
Did you create them with variable bit rate (vbr) / average bit rate (abr) perchance?
Good question, one might think the output of the programs I quoted above would tell us that…
Usually I use my lame.sh script that contains this line

Code: Select all

lame -b $bitrate -q 2 
… I think I have to look up again how lame does things since the last time I updated lame.sh was 2009.

Added in 3 minutes 45 seconds:
M. Eerie wrote:
01 Mar 2022, 09:10
If so, you could try to rip them again with constant bit rate (cbr) and then concatenate.
When I have to re-encode the CD anew I would create one single file out of it and keep the separate ones as well.

And using abcde for ripping and encoding and not my lame.sh (since my own solution lacks the id3 tag creation)
Cheers!
Yours Rava

Post Reply