Video Transcoding, video

Source: Internet
Author: User

Video Transcoding, video

/// <Summary> /// convert to MP4 format /// </summary> /// <param name = "fromFilePath"> </param> /// <returns> </returns> public static string ToMp4 (string fromFilePath) {string ffmpeg = HttpContext. current. server. mapPath ("/") + "ffmpeg \ bin \ ffmpeg.exe"; // path of the ffmpeg execution file: int lastIndexPort = fromFilePath. lastIndexOf (". "); string toPathFileName = fromFilePath. substring (0, lastIndexPort) + ". mp4 "; if ((! System. IO. file. exists (ffmpeg) {return string. empty;} // convert the string Command = "-I \" "+ fromFilePath +" \ "-c: v libx264-strict-2 \ "" + toPathFileName + "\" "; using (System. diagnostics. process p = new System. diagnostics. process () {p. startInfo. fileName = ffmpeg; p. startInfo. arguments = Command; // p. startInfo. workingDirectory = HttpContext. current. server. mapPath ("~ /Temp/"); p. startInfo. useShellExecute = false; p. startInfo. redirectStandardInput = true; p. startInfo. redirectStandardOutput = true; p. startInfo. redirectStandardError = true; p. startInfo. createNoWindow = false; p. start (); p. beginErrorReadLine (); p. waitForExit (); p. dispose (); return toPathFileName ;}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.