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
                }
            }
  • 相关阅读:
    uniapp数据循环带参数拼接方法
    UniApp页面跳转
    layui表单提交时关闭默认刷新页面
    js计时器
    Jquery 鼠标移入移出事件
    jquery常用ajax请求
    易宝网上支付接口的实现
    不使用缓存和不同缓存下程序的效率测试
    Mysql常见指令--常用的命令
    PHP冒泡与快速排序法
  • 原文地址:https://www.cnblogs.com/ZhengHengWU/p/12719490.html
Copyright © 2011-2022 走看看