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
                }
            }
  • 相关阅读:
    hibernateValidator 升级
    java异常
    reids过期键三种删除策略
    hashmap源码探究
    http知识梳理1
    GregorianCalendar类的使用
    计算机网络笔记
    List的toArray方法
    实习周记一
    vue指令详解
  • 原文地址:https://www.cnblogs.com/ZhengHengWU/p/12719490.html
Copyright © 2011-2022 走看看