C# 使用ffmpeg.exe进行音频转换完整demo-asp.net转换代码
C# 使用ffmpeg.exe进行音频转换完整demo-asp.net转换代码
上一篇说了在winform下进行调用cmd.exe执行ffmpeg.exe进行音频转换完整demo.后来我又需要移植这个方式到asp.net中,但是asp.net和winform程序有很多不同。
需要修改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(); //StreamReader reader = process.StandardOutput;//截取输出流 string outStr = process.StandardOutput.ReadToEnd(); process.Close(); return outStr; } catch (Exception ex) { return "error" +ex.Message; } } |
注意:构造用户密码,假定密码为123,必须一个字符一个字符的添加 !
2、在asp.net中调用方式:
1
2
3
4
5
6
7
8
|
protected void Button1_Click( object sender, EventArgs e) { string fileName = "d:\\2222.amr" ; string targetFileName = "d:\\2222.mp3" ; WavConvertAmr.WavConvertToAmr toamr = new WavConvertAmr.WavConvertToAmr(); string remsg = toamr.ConvertToAmr(Server.MapPath( "./ffmpeg/" ), fileName, targetFileName); } |
将ffmpeg.exe放在网站的目录ffmpeg的下面
在asp.net要注意ffmepg的路径:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
./当前目录 /网站主目录 ../上层目录 ~/网站虚拟目录 如果当前的网站目录为E:\wwwroot 应用程序虚拟目录为E:\wwwroot\company 浏览的页面路径为E:\wwwroot\company\news\show.asp 在show.asp页面中使用 Server.MapPath( "./" ) 返回路径为:E:\wwwroot\company\news Server.MapPath( "/" ) 返回路径为:E:\wwwroot Server.MapPath( "../" ) 返回路径为:E:\wwwroot\company Server.MapPath( "~/" ) 返回路径为:E:\wwwroot\company server.MapPath(request.ServerVariables( "Path_Info" )) Request.ServerVariables( "Path_Translated" ) 上面两种方式返回路径为 D:\wwwroot\company\news\show.asp
|
转载网址:
http://www. suxxxxxxxxchso.com/projecteactual/csharp-ffmpeg-demo-mp3-amr-mp4-asp.net.html
C# 使用ffmpeg.exe进行音频转换完整demo-asp.net转换代码的更多相关文章
- C# 使用ffmpeg.exe进行音频转换完整demo
今天在处理微信的开发接口时候,发现微信多媒体上传接口中返回的音频格式是amr.坑人的是现在大部分的web 播放器,不支持amr的格式播放.试了很多方法都不行. 没办法,只要找一个妥协的解决方案:将am ...
- .net 使用ffmpeg.exe进行音频转码
#region 音频转换 private int AudioIntervalTime = 100, iAudio = 0; private string strPath = "D:\\web ...
- C++调用ffmpeg.exe提取视频帧
有时候,我们获得一段视频,需要将其中的每一帧都提取出来,来进行一些相关的处理,这时候我们就可以需要用到ffmpeg.exe来进行视频帧的提取. ffmpeg简介:FFmpeg是一套可以用来记录.转换数 ...
- FFmpeg命令行工具学习(三):媒体文件转换工具ffmpeg
一.简述 ffmpeg是一个非常强大的工具,它可以转换任何格式的媒体文件,并且还可以用自己的AudioFilter以及VideoFilter进行处理和编辑.有了它,我们就可以对媒体文件做很多我们想做的 ...
- 使用ffmpeg.exe进行转码参数说明
使用ffmpeg.exe进行转码参数说明 摘自:https://blog.csdn.net/coloriy/article/details/47337641 2015年08月07日 13:04:32 ...
- ffmpeg.exe dos下怎么用 放在哪里
系统:windows 7 1.先看dos界面,win7下这里输入cmd, 看路径 2.把下载的ffmpeg.exe复制到这个路径下 3.这就可以用命令了 1.mp4说明这个文件是跟ffmpeg.ex ...
- 最简单的基于FFMPEG+SDL的音频播放器 ver2 (采用SDL2.0)
===================================================== 最简单的基于FFmpeg的音频播放器系列文章列表: <最简单的基于FFMPEG+SDL ...
- 最简单的基于FFMPEG+SDL的音频播放器 ver2 (採用SDL2.0)
===================================================== 最简单的基于FFmpeg的音频播放器系列文章列表: <最简单的基于FFMPEG+SDL ...
- [原]通过配合ffmpeg.exe获取视频文件时长
import subprocess import os import time def getTime(flvpath,fid): #file_str = '1.flv' file_str = flv ...
随机推荐
- CentOS下查看进程和删除进程
1. 在 LINUX 命令平台输入 1-2 个字符后按 Tab 键会自动补全后面的部分(前提是要有这个东西,例如在装了 tomcat 的前提下, 输入 tomcat 的 to 按 tab).2. ps ...
- 【LeetCode OJ】Symmetric Tree
Problem Link: https://oj.leetcode.com/problems/symmetric-tree/ To solve the problem, we can traverse ...
- 10大白帽黑客专用的 Linux 操作系统
原文出处: Irshad Pathoor 译文出处:Linux中国 欢迎分享原创到伯乐头条 今天让我们来介绍十个黑客专用的操作系统,它们被白帽黑客用作渗透测试的工具.这里我把 Kali Lin ...
- PHP 记录日志
public function writelog($message) { $logFileDir = LOG_PATH; $logFile = 'monitor' . date('Y-m-d') . ...
- 《HP大规模敏捷开发实践》读书笔记
读这本书的心得,敏捷是实践出来的,哪怕不懂srcum**等方法,只要坚持心中的价值观,朝一个方向改进,哪怕不能“任何时候都拥有符合发布要求的代码”,今天比昨天好,也是成功. 通过业务分析确定开 ...
- linux查看一条命令的执行结果是1还是0
echo $? 0为成功 其他为失败
- System.Collections.Generic的各容器类的用法
演示System.Collections.Generic的各容器类的用法. 包括:Dictionary,KeyValuePair,SortedDic tionary,SortedList,HashSe ...
- C# 加载 SQLite DLL问题
/********************************************************************************* * C# 加载 SQLite DL ...
- lua userdata
#define metatablename "studentlib.06-11-11" /** * utility functions */ static int pusherro ...
- 用MFC如何对子对话框进行初始化
通常情况下,我们在创建子对话框的类时.cpp文件中并不会自动生成initdialog函数,但我们的很多操作都需要用到initdialog初始化函数,如果你直接在类的头文件中去定义一个初始化函数,然后在 ...