Media file conversion using FFMPEG & C #

Source: Internet
Author: User
Using system;
Using system. Data ;
Using system. Configuration ;
Using system. Web ;
Using system. Web . Security ;
Using system. Web . UI ;
Using system. Web . UI . Webcontrols ;
Using system. Web . UI . Webcontrols . Webparts ;
Using system. Web . UI . Htmlcontrols ;
Using system. Diagnostics ;
Using sharpffmpeg;
Using system. Io ;
Public partial class _ default: system. Web . UI . Page
{
Protected Void Page_load ( Object sender, eventargs E )
{

Using ( System. Diagnostics . Process P = new system. Diagnostics . Process ( ) )
{
String Exepath;
String Apppath = request. Physicalapplicationpath ;
String Inputpath = apppath + "Source" ;
String Outputpath = apppath + "Destination" ;
// Get the Application Path
Exepath = apppath + "Ffmpeg.exe" ;
String Filename = "Bear. wmv" ;
String Videosource = page. Mappath ( "Bear. wmv" ) ;
String Videotarget = page. Mappath ( "" ) + "\\Video. FLV" ;
String Cmd = "-I\"" + Inputpath + "\\" + Filename + "\" \"" + Outputpath + "\\" + Filename. Remove ( Filename. Indexof ( "." ) ) + ". Avi" + "\"" ;
String Strcommand = page. Mappath ( "Ffmpeg.exe" ) ;
// To covert into JPEG file
// String imgargs = "-I \" "+ inputpath +" \ "+ filename. remove (filename. indexof (". ") + ". WMV "+" \ "-F image2-ss 1-vframes 1-s 280x200-An \" "+ outputpath +" \ "+ filename. remove (filename. indexof (". ") + ". jpg "+ "\"";
String Imgargs = "-I\"" + Inputpath + "\\" + Filename. Remove ( Filename. Indexof ( "." ) ) + ". Wmv" + "\"-Ar 22050-AB 32-F FLV\"" + Outputpath + "\\" + Filename. Remove ( Filename. Indexof ( "." ) ) + ". FLV" + "\"" ;

String Strarguments = "-I" + Videosource + videotarget;
P. Startinfo . Filename = Exepath;
P. Startinfo . Arguments = Imgargs;
P. Startinfo . Useshellexecute = False ;
P. Startinfo . Redirectstandarderror = True ;
P. Startinfo . Redirectstandardoutput = False ;
P. Startinfo . Createnowindow = True ;
P. Startinfo . Windowstyle = System. Diagnostics . Processwindowstyle . Hidden ;
P. Start ( ) ;
P. Waitforexit ( 50 * 1000 ) ;

}
}
}
 

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.