using System;
using System.Threading;
using System.IO;
using System.Diagnostics;
using System.Security;

public partial class cowala_201512Chritmas_amrtest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
      changedPlay.Visible = false;
    }
    }

    protected void Ffmpeg_Click(object sender, EventArgs e)
    {
        if (AmrFileUp.HasFile)
        {
            string key = AmrFileUp.FileName;
            string savepath = Server.MapPath("~/upload/amr/") + key;
            AmrFileUp.SaveAs(savepath);

            string mp3SavePth = Server.MapPath("~/upload/mp3/") + key.Split('.')[0].ToString() + ".mp3";

            if (!string.IsNullOrEmpty(ConvertToMp3(savepath, mp3SavePth)))
            {
                changedPlay.Visible = true;
                changedPlay.Attributes.Add("src", "upload/mp3/" + key.Split('.')[0].ToString() + ".mp3");
                Response.Write("<script>alert('转换成功!');</script>");
            }
        }
    }

    public string ConvertToMp3(string pathBefore, string pathLater)
    {
        string c = Server.MapPath("/ffmpeg/") + @"ffmpeg.exe -i " + pathBefore + " " + pathLater;
        string str = RunCmd(c);
        return str;
    }

    /// <summary>
    /// 执行Cmd命令
    /// </summary>
    private string RunCmd(string c)
    {
        try
        {
            ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
            info.RedirectStandardOutput = false;
            info.UseShellExecute = false;
            Process p = Process.Start(info);
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.Start();
            p.StandardInput.WriteLine(c);
            p.StandardInput.AutoFlush = true;
            Thread.Sleep(1000);
            p.StandardInput.WriteLine("exit");
            p.WaitForExit();
            string outStr = p.StandardOutput.ReadToEnd();
            p.Close();

            return outStr;
        }
        catch (Exception ex)
        {
            return "error" + ex.Message;
        }
    }
}

  

amr转MP3的更多相关文章

  1. ffmpeg centos6.5上安装(测试 amr 转换为 mp3)

    1. 下载相关源码包 wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz wget http://sourcefo ...

  2. 解决linux AMR转MP3出现转码成功却无法播放的问题

    根据帖子:http://blog.csdn.net/z313731418/article/details/50218341  的提示,在linux安装ffmpeg,确实在linux下使用命令可以将am ...

  3. window64 PHP ffmpeg详解简单上手 音频amr转mp3

    从网上找了一大堆关于window 64 ffmpeg的信息,都是又长又不关键,让人难消化. 我只要简单的amr转MP3格式而已. 终于搞明白.自己总结了下! 希望能帮助到喜欢言简意赅,一眼上手的同学. ...

  4. java实现windows下amr转换为mp3(可实现微信语音和qq语音转换)

    最近做一个项目需要将微信的语音文件放在页面进行播放,查了好多资料发现,web页面直接播放并没有一个好的解决方案,于是就想到了先将amr文件转换成易于在页面播放的mp3文件,然后在进行播放,现在将amr ...

  5. AMR 转mp3 失败

    private void changeToMp3(String sourcePath) { File source = new File(sourcePath); String mp3TargetPa ...

  6. jav音频格式转换 ffmpeg 微信录音amr转mp3

    项目背景: 之前公司开发了一个微信公众号,要求把js-sdk录音文件在web网页也能播放.众所周知,html的<audio>标签ogg,mp3,wav,也有所说苹果safari支持m4a格 ...

  7. php自定义函数: amr转mp3格式

    <?php function amr2mp3($file){ if (file_exists($file . '.mp3') == true) { return; } else { $param ...

  8. .net 音频转换 .amr 转 .mp3 (ffmpeg转换法)

    最近看来是跟声音干上了啊! 音频转换的第二种方法,这种方法相对第一种来说,要简单的多! 首先,你得下载个“ffmpeg.exe” 插件,然后把它放到你的项目中,如下图: 程序中会调用该文件,以助于转换 ...

  9. .net 音频转换 .amr 转 .mp3 (七牛转换法)

    .amr 用于移动设备的音频,压缩比比较大,多用于人声.通话,效果还行!所以,移动设备多采用amr格式来进行录存!比较常见的例子:通话录音,微信语音以及录音等! 这个鬼,用两个字来形容,就是“蛋疼”: ...

随机推荐

  1. VideoToolbox硬件编解码H.264视频流错误码

    如果你不能找到在VTD中的错误代码我决定只包括他们在这里. (同样,所有这些错误,并更可以在里面VideoToolbox在Project Navigator中找到.本身).  您将获得无论是在VTD中 ...

  2. fastclick 解决js穿透问题

    http://www.tuicool.com/articles/VniQRr http://www.cnblogs.com/MrBackKom/archive/2012/06/26/2564501.h ...

  3. Dictionary和Hashtable的一些异同

    Dictionary和Hashtable 区别: Dictionary和Hashtable 区别 Dictionary Hashtable  支持范型 不支持 需要自己做线程同步 通过调用 Synch ...

  4. SQL日期格式,转自will哥

    我之前一直認為 SQL Server 針對日期處理的函數不夠多(如果跟 MySQL 比較),尤其是處理日期欄位轉字串的時候,常常因為要輸出特定的格式而懊惱不已,常常一不小心就寫了一長串,很不易閱讀. ...

  5. CentOS6.5源码安装python3.5.2

    前提: 1.实现自动补全需要安装模块 readline-devel (yum install -y readline-devel) 2.实现支持SSL协议需安装模块 openssl-devel (yu ...

  6. 百度音乐API抓取

    百度音乐API抓取 前段时间做了一个本地音乐的播放器 github地址,想实现在线播放的功能,于是到处寻找API,很遗憾,不是歌曲不全就是质量不高.在网上发现这么一个APIMRASONG博客,有“获取 ...

  7. tcp转发

    Proxy.java package com.dc.tcp.proxy; import java.io.IOException; import java.net.ServerSocket; impor ...

  8. 全球首个全流程跨平台界面开发套件,PowerUI分析

    一.       首个全流程跨平台界面开发套件,PowerUI正式发布 UIPower在DirectUI的基础上,自主研发全球首个全流程跨平台界面开发套件PowerUI(PUI)正式发布,PowerU ...

  9. REMOVE ONCLICK DELAY ON WEBKIT FOR IPHONE

    Developing on the webkit for iPhone I encountered a curious delay ononClick events. It seems that th ...

  10. 利用target的特性,可以实现纯css的tab效果切换

    基础知识: :target起作用的是href连接到的位置 如 <a href="#tab1">tab1</a> <div id="tab1& ...