Search code examples
c#windows-phone-8mp3naudio

WP 8.1 Trimming MP3 FILES


Is there a way to trim a mp3 file? I did some research and every search was leading me to NAudio. However NAudio doesn't support WP8.1. Actually I don't think it support any version of windows phone.

Is there any other way to trim a mp3 file? MP3s are made of frames and ID3 tags. Is there a helper that could read mp3 frames and then copy them into a new file?


Solution

  • An MP3 file is a collection of MPEG frames that you can manipulate fairly easily. If you read the NAudio source code (specifically the Mp3Frame class) you'll find a fairly good set of C# code for reading the individual frames. From there you can index the frames, figure out their positions in time and copy out only the ones you're interested in to the output file.

    It may be a bit more complex than that, but have a look at Mark's code in and around the Mp3Frame class for some more information on how it works.

    Oh, and don't forget to credit him if you use his code.