修剪一个MP3编程方式方式

2023-09-03 00:42:38 作者:有些爱祇能掩于岁月

什么是编程修剪一个MP3文件的最好方法。例如,说我想摆脱前2分钟或者最后2分钟,或两者兼而有之。有没有好的办法从.NET做到这一点?或.NET呼唤一个命令行工具?

What is the best way to trim a mp3 file programatically. For example, say I want to get rid of the first 2 minutes or last 2 minutes or both. Is there a good way to do this from .NET? Or .NET calling out to a command line tool?

感谢。

推荐答案

有两种方法可以修剪MP3文件:

There are two approaches to trimming MP3 files:

首先,转换为WAV,修剪掉你不想要的样品,然后再转换回MP3。其缺点是会有质量的过程中非常轻微损失。其优点是,你会发现大量的命令行工具做转换为你,让你简单地修剪WAV文件自己(的 n音讯将让你这样做)。

First, convert to WAV, trim off the samples you don't want, and then convert back to MP3. The disadvantage is that there will be a very slight loss of quality in the process. The advantage is that you will find plenty of command line tools to do the conversions for you, leaving you simply to trim the WAV file yourself (NAudio would let you do that).

二,解析MP3帧本身,而丢掉整个帧。它不给你那么多的粒度但在这个过程中没有质量损失。还需要能够理解的CBR和VBR的MP3帧的格式,以及ID3帧。大约有各种.NET库可以读取这些,但是你仍然需要写$ C $相当数量的ç自己。

Second, parse the MP3 frames themselves, and throw away whole frames. It doesn't give you so much granularity but there is no loss of quality in the process. You also need to be able to understand the format of the CBR and VBR MP3 frames as well as ID3 frames. There are various .NET libraries around that can read these, but you will still need to write a fair amount of code yourself.