• 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
                }
            }
  • 相关阅读:
    OC-数组类
    OC-字符串函数
    C——位操作
    C——字符串练习
    C语言——指针习题
    指针数组和数组指针
    数组指针和指针数组的区别
    cocos2d-iphone中兼容iphone/ipad的问题
    一个Universal程序还是iPhone、iPad俩个版本 ?
    objective-c获取自1970年以来的毫秒数
  • 原文地址:https://www.cnblogs.com/ZhengHengWU/p/12719490.html
Copyright © 2020-2023  润新知