n音讯分割MP3文件 [英] NAudio to split mp3 file

查看:180
本文介绍了n音讯分割MP3文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的音频或MP3的东西,一直在寻找一种方式有一个特点,拆分在C#中的MP3文件,asp.net。谷歌搜索有一个良好的3天没有多少有很大的帮助后,我希望有人在这里可以点我到正确的方向。

I am very new to audio or mp3 stuff, was looking for a way to have a feature to split an mp3 file in C#, asp.net. After googling for a good 3-day without much of a great help, I am hoping that somebody here can point me to a right direction.

我可以使用n音讯做到这一点?有什么样code是什么?先谢谢了。

Can I use NAudio to accomplish this? Is there any sample code for that? Thanks in advance.

推荐答案

我的最终解决方案拆分在C#中的MP3文件是使用n音讯。下面是一个示例脚本,希望它可以帮助别人社区:

My final solution to split mp3 file in c# is to use NAudio. Here is a sample script for that, hope it helps someone in the community:

string strMP3Folder = "<YOUR FOLDER PATH>";
string strMP3SourceFilename = "<YOUR SOURCE MP3 FILENAMe>";
string strMP3OutputFilename = "<YOUR OUTPUT MP3 FILENAME>";

using (Mp3FileReader reader = new Mp3FileReader(strMP3Folder + strMP3SourceFilename))
{
    int count = 1;
    Mp3Frame mp3Frame = reader.ReadNextFrame();
    System.IO.FileStream _fs = new System.IO.FileStream(strMP3Folder + strMP3OutputFilename, System.IO.FileMode.Create, System.IO.FileAccess.Write);

    while (mp3Frame != null)
    {
        if (count > 500) //retrieve a sample of 500 frames
            return;

        _fs.Write(mp3Frame.RawData, 0, mp3Frame.RawData.Length);
        count = count + 1;
        mp3Frame = reader.ReadNextFrame();
     }

     _fs.Close();
}

感谢马克·希思的建议这一点。

Thanks to Mark Heath's suggestion for this.

所需的命名空间是NAudio.Wave。

这篇关于n音讯分割MP3文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆