开发者

Audio (mp3) editing in C

What I wish to do is to "split" an开发者_如何学Go .mp3 into two separate files, taking duration as an argument to specify how long the first file should be.

However, I'm not entirely sure how to achieve this in C. Is there a particular library that could help with this? Thanks in advance.


I think you should use the gstreamer framework for this purpose. So you can write an application where you can use existing plugins to do this job. I am not sure of this but you can give it a try. Check out http://gstreamer.freedesktop.org/ For queries related to gstreamer: http://gstreamer-devel.966125.n4.nabble.com/

If you don't find any library in the end, then understand the header of a mp3 file and divide the original file into any number of parts and add individual headers to them. Its not gonna be easy but its possible.


It can be as simple as cutting the file at a position determined by the mp3 bitrate and duration requested. But:

  • your file should be CBR - that method won't work on ABR or VBR files, because they have different densityes
  • your player should be robust enough not to break if it gets partial mp3 frame at a start. Most of the playback libraries will handle mp3s split that way very gracefully.

If you need more info, just ask, I am on the mobile and can get you more info later.

If you want to be extra precise when cutting, you can use some library to parse mp3 frame headers, and then write frames that you need. That way, and the way mentioned before, you'll get only frame alignment as a minimum, and you have to live with thaty and that's 40ms.

If that isn't enough, you must decode mp3 to PCM, split at sample boundary, then recompress to mp3 again.

Good luck

P.s.

When you say split, I hope you don't expect them to play one after another with no audible 'artifacts'. Mp3 frames aren't self-sufficient, as they carry information from the frame before.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜