C# 使用ffmpeg.exe进行音频转换完整demo
需要修改WavConvertToAmr的方法,支持asp.net
1、WavConvertToAmr修改执行权限:如果在windows server中可能会遇到权限问题,需要配置IIS权限:
先从IIS中找到你的网站,在右键--【属性】中看看使用的应用程序池是哪个,然后【在应用程序池】目录下找到它,,右键---【属性】
找到【标识】选项卡,再找到【预定义账户】,在后边的下拉菜单中选择“本地系统”就可以了!
这样一来,你的网站就可以随心所欲的执行cmd命令了,其实不仅仅是执行cmd命令,简直是至高无上的权限!
提醒一下,这样更改的是应用程序池权限,因此所有使用这个应用程序池的网站都有很高的权限,这是相当危险的,还须谨慎使用!!
这个方法存在危险,也通过设置执行的用户名和密码来设置:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/// <summary>
/// 执行Cmd命令
/// </summary>
private string Cmd(string c)
{
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UserName = "user";
//构造用户密码,假定密码为123,必须一个字符一个字符的添加
System.Security.SecureString password = new System.Security.SecureString();
password.AppendChar(‘p‘);
password.AppendChar(‘a‘);
password.AppendChar(‘s‘);
password.AppendChar(‘s‘);
process.StartInfo.Password = password;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
process.StandardInput.WriteLine(c);
process.StandardInput.AutoFlush = true;
Thread.Sleep(1000);
process.StandardInput.WriteLine("exit");
process.WaitForExit();
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/68868.html