zoukankan      html  css  js  c++  java
  • C#Amr转MP3

     

    一:打开管理NuGet程序包进行安装NReco.VideoConverter.dll

    二:实践

            /// <summary>
            /// amr转化为mp3
            /// </summary>
            /// <param name="model"></param>
            public void AmrConvertMp3(PmsProjectFilesModel model)
            {
                if (model.FileType == 2)
                {
                    var filePath = Config.FilePath + "\" + model.FilePath;
                    var newFilePath = Config.FilePath + "\" + model.FilePath.Replace(".amr", ".mp3");
    
                    //万企链传amr,需转化为mp3
                    if (".amr".Equals(model.FileExt, StringComparison.OrdinalIgnoreCase))
                    {
                        //转MP3
                        if (File.Exists(filePath) && !File.Exists(newFilePath))
                        {
                            CommonMethod.FormatConversion(filePath, "amr", newFilePath, "mp3");
                        }
                    }
                }
            }
            /// <summary>
            /// 格式转化
            /// </summary>
            /// <param name="inputFile">源文件路径</param>
            /// <param name="inputFormat">源文件格式</param>
            /// <param name="outFile">转化后文件路径</param>
            /// <param name="outFormat">转化后文件格式</param>
            public static void FormatConversion(string inputFile, string inputFormat, string outFile, string outFormat, int audioSampleRate = 44100)
            {
                try
                {
                    new FFMpegConverter().ConvertMedia(inputFile, inputFormat, outFile, outFormat, new ConvertSettings { AudioSampleRate = audioSampleRate });
                }
                catch (Exception ex)
                {
                    throw ex;
                    // ignored
                }
            }
  • 相关阅读:
    GNU软件FTP下载汇总
    设置git的代理服务器
    今天发现一个Convert.ToDateTime的异常,算不算微软的bug呢?
    无线电空间传输损耗衰减计算(转帖)
    使用ArcGis10.2通过Dem提取山顶点(原创)
    VC++编译zlib
    VC++编译libpng
    vc++编译libtiff4.0.4
    VC++编译GSL
    libCEF总结02字符串
  • 原文地址:https://www.cnblogs.com/ZhengHengWU/p/12719490.html
Copyright © 2011-2022 走看看