简体   繁体   中英

Converting mp4 to webm , ogg formats

Currently i need to convert mp4 video to webm and ogg . To convert mp4 to webm i have used "ffmpeg.exe". I am running following code to convert video mp4 to webm.

[DllImport("User32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
public void mciConvertWavMP3(string fileName, bool waitFlag)
{

    string savepath = Server.MapPath(fileName);
    string destpath = Server.MapPath(fileName);
    string pworkingDir = Server.MapPath("~/ffmpeg/");

 // string outfile = "-b:a 16 --resample 24 -m j " + savepath + " " + savepath.Replace(".wav", ".mp3") + ""; //--- lame code
  //  string outfile = "-b 192k -i " + savepath + " " + destpath.Replace(".mp4", ".webm");
   // string outfile = "ffmpeg -i " + savepath + " -acodec libvorbis -ac 2 -ab 96k -ar 44100 -b 345k -s 640x360 " + Server.MapPath("output-file.webm");

    string outfile = "ffmpeg -i \"test7.mp4\" -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis \"" + Server.MapPath("output-file.webm") + "\"";
   // string outfile = "ffmpeg -i \""+fileName+"\" -codec:v libvpx -quality good -cpu-used 0 -b:v 600k -qmin 10 -qmax 42 -maxrate 500k -bufsize 1000k -threads 2 -vf scale=-1:480 -an -pass 1 -f webm /dev/null";

    System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
    psi.FileName = pworkingDir+"ffmpeg.exe";
    psi.Arguments = outfile;
    psi.UseShellExecute = true;
    psi.CreateNoWindow = false;
    System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
    Thread.Sleep(1000);// utput.webm
    if (waitFlag)
    {
        p.WaitForExit();
        // wait for exit of called application 
    }
}

I kept my project folder in D:/ drive

When i am running from Command promt its working fine. But when i am running this code its not working fine.

Formal errors which i am getting are :

" unable to find a suitable output format for 'ffmpeg' " kind of errors. SO please can any one help to solve this issue.

Thank & Regards

remove "ffmpeg" from the

string outfile = "ffmpeg -i \"test7.mp4\" -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis \"" + Server.MapPath("output-file.webm") + "\"";

you already pass app name in psi.FileName variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM