"Losslessly" trim an MP3 file

13

2

I have got an mp3 file, let's say it is 25 minutes long. I understand that any software is capable of extracting the first 20 minutes of the file as a new MP3 file. However, I would like to find a solution that would do this "loss-lessly", i.e., keep the original MP3 blocks and just use the first 4/5 of the blocks and modify the header accordingly. This way, no quality loss is imposed by the extraction process. I'm cutting the file in a space where couple seconds of silence happen, so cutting between blocks should be possible.

(A good analogy would be to take a cut-out of a JPG file at the boundaries of the blocks simply by taking only the blocks inside the cutout. One can decode the file, cut it and encode it again, but with a quality loss.)

(As far as I know, by default, software would decode the file into a waveform, extract the demanded part and encode it again using the MP3 algorithm. This is not what I want, since the 2nd compression unnecessarily reduces the quality.)

(I prefer a linux solution, but I can access windows as well.)

yo'

Posted 2015-11-08T19:33:51.927

Reputation: 381

Question was closed 2015-11-13T09:04:33.580

mp3 is not lossless. – DavidPostill – 2015-11-08T19:38:27.070

4@DavidPostill I do know. But each decode-encode step demages the file further; I want to avoid this. I tried to clarify myself. – yo' – 2015-11-08T19:39:40.870

Just that you know, single reencodings quality penalty will probably not be noticed to the human ear. – iTayb – 2015-11-08T19:55:49.390

Actually in MP3 each frame has a header and since you want to cut from the end you can just cut part of the file off with any file tool you want. It won't be exactly kosher, but the end result is what you want. There is no global header that needs to be modified in any way. If the file has constant bitrate it is easy to calculate the cut point. – Sami Kuhmonen – 2015-11-08T20:09:57.407

1What an interesting question. +1 – Dave – 2015-11-08T20:10:00.267

@SamiKuhmonen I doubt your remark is 100% true, knowing that there are MP3 files for which incorrect length is shown by some software, and that each MP3 file has a header containing the metadata. However, maybe it is possible to trim the file "vulgarly" and then let some special software "repair" the resulting file? Could this work? – yo' – 2015-11-08T20:13:42.667

@yo' Then those applications are actually broken, since the specification doesn't include any metadata. True, it is common to have it, but not per spec. It might be possible to fix it with tools, if I remember correctly the newer metadata is in the end so it will be stripped in this process anyway and could be replaced. – Sami Kuhmonen – 2015-11-08T20:16:19.580

@SamiKuhmonen Thanks. I'll make some experiments, but not today. I'll keep in touch. – yo' – 2015-11-08T20:18:24.460

@Ƭᴇcʜιᴇ007 It seems to be what I'm looking for, but since I can't test it now, I won't confirm the dupe. Thanks anyway for finding it, I wasn't able to find it. – yo' – 2015-11-08T21:34:12.330

1Just to make this clear: Just cutting the end of an mp3 file will work in the sense that it's playable but most media players will show the wrong duration. @SamiKuhmonen while you are technically correct that the mp3 spec does not include any meta-data specification for the duration, there is a de-facto standard called the XING-header which includes the duration and entry-points for searching in VBR files. – twall – 2017-06-28T14:28:10.327

Answers

6

With linux you can use mp3splt. It has a gui also if you want and is available for linux and windows.

From the man page:

mp3splt is a free command-line utility that allows you to split mp3 and ogg files from several splitpoints, without need of decoding and reencoding.

Extract first 20 minutes from your file:

mp3splt -f original.mp3 0.0 20.0

cristi

Posted 2015-11-08T19:33:51.927

Reputation: 453

2

mp3DirectCut is for Windows. But the website states that it should work on Linux with Wine.

Max

Posted 2015-11-08T19:33:51.927

Reputation: 988