开发者

How can I concatenate two mp3 files with different bit rates

I have FFmpeg installed on my linux web server. When I execute the following code, I have intermittent results.

I think 开发者_JAVA技巧I have figured out that the MP3s do not compile when they have different bitrates.

exec ('cat '. $pair['source_file'] . ' ' . $pair['translated_word_file'] . '>' . $temp_mp3);

I might have found some articles online that reference taking them apart and then bundling them back together at a consistent bitrates.

I have confirmed that this won't really work with basic "cat" function and that "sox" can be used IF they have the same sample rate.

The issue now becomes "What is the best way to get them to the same sample rate?"


You will need to find a way to strip out all of the ID3 tags and other crap, and break it down to just the MP3 stream. Then, cut and splice on the MP3 frames. You shouldn't leave a frame incomplete!

If you have a proper stream of frames and don't have any random data (tags) in the middle of the stream, then you should have no problems splicing files together, even if their bitrate changes!

However! You should probably stick to the same bitdepth (16-bit for example) and sample rate (44.1kHz for example). You have confused these two parameters with the output bitrate in your question.

See this: http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html

And this: http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm

Edit: A big caveat to this is the bit reservoir. While you can create a stream and split on frames, some data may be corrupt if the bit reservoir is in use. I previously based this answer on my experience with a few streams. A couple years later, I now know that you cannot reliably splice on frames for all streams.


convert first the bitrate of one mp3 so that both have uniform bitrate. Then do the concatenation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜